Skip to content
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

test: migrate TestModule to JUnit 5 #4544

Merged
merged 3 commits into from
Jan 22, 2022

Conversation

MartinWitt
Copy link
Collaborator

#3919

Change Log

The following bad smells are refactored:

ExpectedException

The expected annotation value should be removed from test methods, and replaced with JUnit 5 assertThrows.

JUnit4-@test

The JUnit 4 @Test annotation should be replaced with JUnit 5 @Test annotation.

JUnit4Assertion

The JUnit4 assertion should be replaced with JUnit5 Assertions.

Junit4-@afterclass

The JUnit 4 @AfterClass annotation should be replaced with JUnit 5 @AfterAll annotation.

Junit4-@BeforeClass

The JUnit 4 @BeforeClass annotation should be replaced with JUnit 5 @BeforeAll annotation.

Junit4-@ignore

The JUnit 4 @Ignore annotation should be replaced with JUnit 5 @Disabled annotation.

The following has changed in the code:

Junit4-@BeforeClass

  • Replaced @BeforeClass annotation with @BeforeAll at method setUp

Junit4-@afterclass

  • Replaced @After annotation with @AfterEach at method tearDown

JUnit4-@test

  • Replaced junit 4 test annotation with junit 5 test annotation in testCompleteModuleInfoContentNoClasspath
  • Replaced junit 4 test annotation with junit 5 test annotation in testModuleInfoShouldBeCorrectlyPrettyPrinted
  • Replaced junit 4 test annotation with junit 5 test annotation in testModuleInfoWithComments
  • Replaced junit 4 test annotation with junit 5 test annotation in testDirectiveOrders
  • Replaced junit 4 test annotation with junit 5 test annotation in testGetParentOfRootPackageOfModule
  • Replaced junit 4 test annotation with junit 5 test annotation in testGetModuleAfterChangingItsName
  • Replaced junit 4 test annotation with junit 5 test annotation in testModuleNames
  • Replaced junit 4 test annotation with junit 5 test annotation in testMultipleModulesAndParents
  • Replaced junit 4 test annotation with junit 5 test annotation in testModuleComplianceLevelException
  • Replaced junit 4 test annotation with junit 5 test annotation in testModuleOverlappingPackages

Junit4-@ignore

  • Replaced @Ignore annotation with @Disabled at method testMultipleModulesAndParents

ExpectedException

  • Removed expected annotation from test method testModuleComplianceLevelException

JUnit4Assertion

  • Transformed junit4 assert to junit 5 assertion in testCompleteModuleInfoContentNoClasspath
  • Transformed junit4 assert to junit 5 assertion in testModuleInfoShouldBeCorrectlyPrettyPrinted
  • Transformed junit4 assert to junit 5 assertion in testModuleInfoWithComments
  • Transformed junit4 assert to junit 5 assertion in testDirectiveOrders
  • Transformed junit4 assert to junit 5 assertion in testGetParentOfRootPackageOfModule
  • Transformed junit4 assert to junit 5 assertion in testGetModuleAfterChangingItsName
  • Transformed junit4 assert to junit 5 assertion in testSimpleModuleCanBeBuilt
  • Transformed junit4 assert to junit 5 assertion in testMultipleModulesAndParents
  • Transformed junit4 assert to junit 5 assertion in testModuleComplianceLevelException
  • Transformed junit4 assert to junit 5 assertion in testModuleOverlappingPackages

 The following has changed in the code:
Removed expected annotation from test method testModuleComplianceLevelException
Replaced @BeforeClass annotation with @BeforeAll at method setUp
Replaced @after annotation with @AfterEach at method tearDown
Replaced @ignore annotation with @disabled at method testMultipleModulesAndParents
Replaced junit 4 test annotation with junit 5 test annotation in testCompleteModuleInfoContentNoClasspath
Replaced junit 4 test annotation with junit 5 test annotation in testModuleInfoShouldBeCorrectlyPrettyPrinted
Replaced junit 4 test annotation with junit 5 test annotation in testModuleInfoWithComments
Replaced junit 4 test annotation with junit 5 test annotation in testDirectiveOrders
Replaced junit 4 test annotation with junit 5 test annotation in testGetParentOfRootPackageOfModule
Replaced junit 4 test annotation with junit 5 test annotation in testGetModuleAfterChangingItsName
Replaced junit 4 test annotation with junit 5 test annotation in testModuleNames
Replaced junit 4 test annotation with junit 5 test annotation in testMultipleModulesAndParents
Replaced junit 4 test annotation with junit 5 test annotation in testModuleComplianceLevelException
Replaced junit 4 test annotation with junit 5 test annotation in testModuleOverlappingPackages
Transformed junit4 assert to junit 5 assertion in testCompleteModuleInfoContentNoClasspath
Transformed junit4 assert to junit 5 assertion in testModuleInfoShouldBeCorrectlyPrettyPrinted
Transformed junit4 assert to junit 5 assertion in testModuleInfoWithComments
Transformed junit4 assert to junit 5 assertion in testDirectiveOrders
Transformed junit4 assert to junit 5 assertion in testGetParentOfRootPackageOfModule
Transformed junit4 assert to junit 5 assertion in testGetModuleAfterChangingItsName
Transformed junit4 assert to junit 5 assertion in testSimpleModuleCanBeBuilt
Transformed junit4 assert to junit 5 assertion in testMultipleModulesAndParents
Transformed junit4 assert to junit 5 assertion in testModuleComplianceLevelException
Transformed junit4 assert to junit 5 assertion in testModuleOverlappingPackages
@MartinWitt
Copy link
Collaborator Author

MartinWitt commented Jan 21, 2022

I changed this assertion to 2 because we have clearly 2 modules, simple module and the unnamed module. I have no clue why this test was ever green.

assertEquals(1, model.getAllModules().size());

@monperrus monperrus merged commit 68751f1 into INRIA:master Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants