Skip to content

Commit 9ac387a

Browse files
committed
Wrap the cms, cades, c509, est.jcajce, pkix.jcajce and crypto.signers.lms AllTests suites in a nested BCTestSetup and make the cades suite extend TestCase, so the Gradle AllTest* test filter no longer rejects every child of their bare TestSuite roots and silently skips the 484 tests they carry, and document the requirement in the test conventions.
1 parent 4c89edd commit 9ac387a

7 files changed

Lines changed: 139 additions & 6 deletions

File tree

‎core/src/test/java/org/bouncycastle/crypto/signers/lms/AllTests.java‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.bouncycastle.crypto.signers.lms;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
45
import junit.framework.TestCase;
56
import junit.framework.TestSuite;
@@ -20,6 +21,25 @@ public static Test suite()
2021
suite.addTestSuite(LMOtsTests.class);
2122
suite.addTestSuite(TypeTests.class);
2223

23-
return suite;
24+
return new BCTestSetup(suite);
25+
}
26+
27+
static class BCTestSetup
28+
extends TestSetup
29+
{
30+
public BCTestSetup(Test test)
31+
{
32+
super(test);
33+
}
34+
35+
protected void setUp()
36+
{
37+
38+
}
39+
40+
protected void tearDown()
41+
{
42+
43+
}
2444
}
2545
}

‎docs/claude/conventions.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Most tests extend `org.bouncycastle.util.test.SimpleTest` (not JUnit). They override `performTest()` and call `fail(msg)` / `isTrue(msg, cond)` / `areEqual(a, b)`. They are *not* discovered by Gradle directly — they're invoked from JUnit `AllTests` / `RegressionTest` wrappers.
66
- `RegressionTest.tests` arrays (one per package) list every `SimpleTest` to be run. When you add a new `SimpleTest`, also add a call from a parent test or from `RegressionTest`.
7+
- **An `AllTests.suite()` must return a `TestSetup` wrapper (`return new BCTestSetup(suite);` with a nested `static class BCTestSetup extends TestSetup`, as in `tsp.test.AllTests`), never a bare `TestSuite`, and the class must `extends TestCase`.** The Gradle test tasks filter on `includeTestsMatching "AllTest*"`, and Gradle's JUnit `MethodNameFilter` applies that pattern to every leaf test; JUnit's `JUnit38ClassRunner.filter()` only knows how to filter a bare `TestSuite`, so a bare suite has every child (`FooTest.testBar`) rejected and Gradle silently reports "no tests found" for it — the suite compiles, is listed nowhere as skipped, and never runs. A `TestDecorator` root is not filterable and so runs whole. Six suites (`cms.test`, `cades.test`, `cert.c509.test`, `est.jcajce`, `pkix.jcajce` in pkix, `crypto.signers.lms` in core — 484 tests, pkix instruction coverage 52% → 67%) sat in that hole until 2026-08. Check a new suite actually appears under `<module>/build/test-results/` after `./gradlew :<module>:test`.
78
- Tests pass `-Dbc.test.data.home=<core/src/test/data>` for fixture lookups.
89
- The `:test` task runs each test class in its own JVM (`forkEvery = 1`).
910

‎pkix/src/test/java/org/bouncycastle/cades/test/AllTests.java‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package org.bouncycastle.cades.test;
22

3+
import java.security.Security;
4+
5+
import junit.extensions.TestSetup;
36
import junit.framework.Test;
7+
import junit.framework.TestCase;
48
import junit.framework.TestSuite;
59

610
public class AllTests
11+
extends TestCase
712
{
813
public static void main(String[] args)
914
{
@@ -19,6 +24,25 @@ public static Test suite()
1924
suite.addTestSuite(CAdESLTTest.class);
2025
suite.addTestSuite(CAdESLTATest.class);
2126

22-
return suite;
27+
return new BCTestSetup(suite);
28+
}
29+
30+
static class BCTestSetup
31+
extends TestSetup
32+
{
33+
public BCTestSetup(Test test)
34+
{
35+
super(test);
36+
}
37+
38+
protected void setUp()
39+
{
40+
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
41+
}
42+
43+
protected void tearDown()
44+
{
45+
Security.removeProvider("BC");
46+
}
2347
}
2448
}

‎pkix/src/test/java/org/bouncycastle/cert/c509/test/AllTests.java‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.bouncycastle.cert.c509.test;
22

3+
import java.security.Security;
4+
5+
import junit.extensions.TestSetup;
36
import junit.framework.Test;
47
import junit.framework.TestCase;
58
import junit.framework.TestSuite;
@@ -19,6 +22,25 @@ public static Test suite()
1922

2023
suite.addTestSuite(C509CertTest.class);
2124

22-
return suite;
25+
return new BCTestSetup(suite);
26+
}
27+
28+
static class BCTestSetup
29+
extends TestSetup
30+
{
31+
public BCTestSetup(Test test)
32+
{
33+
super(test);
34+
}
35+
36+
protected void setUp()
37+
{
38+
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
39+
}
40+
41+
protected void tearDown()
42+
{
43+
Security.removeProvider("BC");
44+
}
2345
}
2446
}

‎pkix/src/test/java/org/bouncycastle/cms/test/AllTests.java‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.bouncycastle.cms.test;
22

3+
import java.security.Security;
4+
35
import javax.crypto.Cipher;
46

7+
import junit.extensions.TestSetup;
58
import junit.framework.Test;
69
import junit.framework.TestCase;
710
import junit.framework.TestSuite;
@@ -61,6 +64,25 @@ public static Test suite()
6164
// ignore
6265
}
6366

64-
return suite;
67+
return new BCTestSetup(suite);
68+
}
69+
70+
static class BCTestSetup
71+
extends TestSetup
72+
{
73+
public BCTestSetup(Test test)
74+
{
75+
super(test);
76+
}
77+
78+
protected void setUp()
79+
{
80+
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
81+
}
82+
83+
protected void tearDown()
84+
{
85+
Security.removeProvider("BC");
86+
}
6587
}
6688
}

‎pkix/src/test/java/org/bouncycastle/est/jcajce/AllTests.java‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.bouncycastle.est.jcajce;
22

3+
import java.security.Security;
4+
5+
import junit.extensions.TestSetup;
36
import junit.framework.Test;
47
import junit.framework.TestCase;
58
import junit.framework.TestSuite;
@@ -18,6 +21,25 @@ public static Test suite()
1821

1922
suite.addTestSuite(ESTClientRedirectTest.class);
2023

21-
return suite;
24+
return new BCTestSetup(suite);
25+
}
26+
27+
static class BCTestSetup
28+
extends TestSetup
29+
{
30+
public BCTestSetup(Test test)
31+
{
32+
super(test);
33+
}
34+
35+
protected void setUp()
36+
{
37+
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
38+
}
39+
40+
protected void tearDown()
41+
{
42+
Security.removeProvider("BC");
43+
}
2244
}
2345
}

‎pkix/src/test/java/org/bouncycastle/pkix/jcajce/AllTests.java‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.bouncycastle.pkix.jcajce;
22

3+
import java.security.Security;
4+
5+
import junit.extensions.TestSetup;
36
import junit.framework.Test;
47
import junit.framework.TestCase;
58
import junit.framework.TestSuite;
@@ -26,6 +29,25 @@ public static Test suite()
2629
suite.addTestSuite(ReasonsMaskTest.class);
2730
suite.addTestSuite(RevocationUtilitiesTest.class);
2831

29-
return suite;
32+
return new BCTestSetup(suite);
33+
}
34+
35+
static class BCTestSetup
36+
extends TestSetup
37+
{
38+
public BCTestSetup(Test test)
39+
{
40+
super(test);
41+
}
42+
43+
protected void setUp()
44+
{
45+
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
46+
}
47+
48+
protected void tearDown()
49+
{
50+
Security.removeProvider("BC");
51+
}
3052
}
3153
}

0 commit comments

Comments
 (0)