New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JUnit migration WIP #3684
JUnit migration WIP #3684
Conversation
cc52dc8
to
ab14007
Compare
Codecov Report
@@ Coverage Diff @@
## master #3684 +/- ##
============================================
- Coverage 33.95% 31.15% -2.81%
+ Complexity 2718 2503 -215
============================================
Files 1163 1163
Lines 24771 24728 -43
Branches 2228 2224 -4
============================================
- Hits 8411 7703 -708
- Misses 15455 16222 +767
+ Partials 905 803 -102
Continue to review full report at Codecov.
|
33f440c
to
cb3ba8c
Compare
Heads up: this will need to be broken out into much smaller individual PRs before it can be merged. It is impossible to review, understand and/or maintain what's going on in 800+ files. |
995bf83
to
7f64d72
Compare
This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
65b3d96
to
ddaf337
Compare
This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This patch has been automatically closed because it has not had recent activity. If you wish to resume work, please re-open the pull request and continue as usual. Thank you for your contributions. |
broken up into several commits |
Complete the migration from junit4 to junit5.
This is a big patch that can't be broken up very well to implement it in individual modules so I organized it in discrete steps. Each commit is a different step in the process. This has been continuously rebased against master and to push missed changes into the correct commit.
- All of the migrations that IDEA can perform automatically:
@BeforeClass
->@BeforeAll
,@After
->@AfterEach
,org.junit.Test
->org.junit.jupiter.api.Test
, etc.-
@Rule
is no longer supported and the functionality to be implemented using theExtension
interface.- In Junit 5, the required
SpringExtension
is inherited bySpringBootTest
and so is almost universally already applied.- Junit 5 has native support for enabling and disabling tests based on runtime conditions.
- Adds
(Disabled|Enabled)IfContinuousIntegration
to replace@ConditionalIgnore(condition = RunningConditionalIntegrationCondition.class)
- Adds
EnabledIfStandalone
to replace the not CI condition. Runs the test iff an environment variableSTANDALONE
is set to 'true'. This is for tests that are only run locally by a single maintainer. To be replaced byEnabledIfSystemProperty
in a later commit.- Adds
EnabledIfPortOpen
to fulfill the other parameter of the old continuous integration condition. Runs the test if something is listening on the given port.org.junit.Assert
toorg.junit.jupiter.api.Assertions
- Most of this just changing the
import
- The order of arguments for the assertions with messages has changed.
- This also removes assertj dependency and reduces hamcrest use.
assertThrows
andassertDoesNotThrow
- Adds
org.apereo.cas.util.Assertions
.-
assertHasRootCause
-assertThrows with a type check for the root cause of the thrown exception. -
assertThrowsOrNot- Wraps
assertThrowsand
assertDoesNotThrowIf an exception is given, the thrown exception is verified against it. If
null` is passed, the block is expected not to throw.ExpectedException
rule toorg.junit.jupiter.api.Assertions.assertThrows
- More explicit interface for expecting exceptions: wrap a statement that should throw an exception in a lambda.
- Can be a little clunky when dealing with checked exceptions because lambdas are not declared as throwing
Exception
(somewhat handled in a later commit).IfProfileValue
to Junit 5EnabledIfSystemProperty
.- May be used to enable specific tests on an individual basis. Exactly the same use case as EnabledIfStandalone
. This will replace
EnabledIfStandalone` in a later commit.assertAll
- Replaces the Mockito rule with
MockitoExtension
.- Abstract classes and interfaces are ignored for tests, sets two classes to be abstract to account for the change.
- Both
@Suite
and@RunWith
are deprecated.- Switch to
@SelectClasses
@Tag
from@Category
and removes the CouchDb category class.- Parameter is required in test initializer (
@BeforeEach
).-
@ParameterizedTest
does not make the argument available to lifecycle callbacks.-
@RepeatedTest
used instead to pull arguments from array.- Most significant changes are made to
BaseTicketRegistryTests
. Most other changes are cleaning up the old references.- Parameter is only needed in tests.
- Uses
@ParameterizedTest
for testing with the parameters.- Changes existing parameter method to work with
@ParameterizedTest
.- Most significant changes are in
AbstractServiceRegistryTests
.- Adds SAML, OAuth, WS, and OIDC as test dependencies to all service registry modules.
- All registry implementations are now tested against all registered service types.
RegexRegisteredService
parameterized testing.- Inlines lifecycle callback so
@ParameterizedTest
may be used.- Renames
AbstractCRLRevocationCheckerTests
toBaseCRLRevocationCheckerTests
as it's no longerabstract
(no abstract methods)- Inlines
AbstractCRLRevocationCheckerTests
constructor to use@ParameterizedTest
.AbstractRegisteredServiceTests
that started running and failing after 10.tests.gradle
so tests run properly again.DefaultCasAttributeEncoderTests
- JUnit5 runtime changes were overloading the test LDAP server.
- TKTK