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

Remove the JUnit dependency in AssertFile #4112

Closed
wants to merge 4 commits into from

Conversation

cppwfs
Copy link
Contributor

@cppwfs cppwfs commented May 10, 2022

resolves #4111

@@ -34,7 +35,7 @@
* queue for inspection.</p>
*/

@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" })
Copy link
Contributor

@hpoettker hpoettker Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really important, but if @ContextConfiguration is replaced with @SpringJUnitConfig, the @ExtendWith(SpringExtension.class) can be omitted, which makes the code a bit leaner.

@SpringJUnitConfig is basically @ContextConfiguration but meta-annotated with @ExtendWith(SpringExtension.class).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to using @SpringJUnitConfig here and in every test class changed in this PR. Another PR could be opened to update all tests cases to use this annotation where appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests have been migrated to JUnit 5 and @SpringJUnitConfig in #4173. When the PR is rebased, the tests in the sample module shouldn't require much change.

@fmbenhassine
Copy link
Contributor

I like how we removed the dependency to any testing library in e90330b! 👍 I'm not sure what would be the best exception to throw when the file comparison fails, but if you think IllegalStateException is not ideal, we can create a custom exception provided by spring-batch-test.

In hindsight, everything in that AssertFile class is already provided by modern testing libraries (JUnit 5, AssertJ, etc) today, so I wonder if that class should be deprecated for removal from Batch in favor of what is provided by other libraries. Wdyt?

@fmbenhassine fmbenhassine removed this from the 5.0.0-M5 milestone Aug 21, 2022
Since I had to add the dependency to the tests to have them pass because of the change made in the previous commit, I decided to migrate all tests to JUnit 5.

2 things to note:
* I used Spring's AssertionErrors on some AssertTrue or AssertFalse methods so that we could maintain the message.
* In a couple of cases the use of assertNotSame that was used had a message, but is no longer supported, so I removed those messages.
The side effect is a breaking change in that it will now throw IllegalStateException instead of the Compare and AssertExceptions provided by JUnit.
@cppwfs cppwfs force-pushed the BATCH-4111 branch 3 times, most recently from 9dda1cb to ccdfba6 Compare August 23, 2022 22:19
fmbenhassine added a commit that referenced this pull request Aug 24, 2022
Revert the removal of `@SpringJUnitConfig`
usage in the test suite of samples.

Related to #4111
@fmbenhassine
Copy link
Contributor

Thank you for the update. Rebased, squashed and merged as 8ca9802. I noticed that the usage of @SpringJUnitConfig was reverted compared to main, so I've put it back in 7e535af. Thank you for this contribution!

@fmbenhassine fmbenhassine changed the title Updated AssertFile to use Jupiter package names Remove the JUnit dependency in AssertFile Aug 24, 2022
@fmbenhassine fmbenhassine added this to the 5.0.0-M5 milestone Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClassNotFound Exception when using AssertFile
3 participants