Test class does not get constructed before every test, causes issues with Mockito
- Dominant language
- Java
- Stars
- 15
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
It seems that the Nested runner fundamentally differs from the standard JUnit runner in that it does not construct a new instance of the Test class before _every_ test. With JUnit you'd see this pattern:
BeforeClass
Construct Instance
Before
Test 1
After
Construct (Fresh) Instance
Before
Test 2
After
...
With Nested, the class is only constructed once. Private fields that need to be recreated every time therefore only get created once. Mocks set up for Mockito similarly only get created once, and this is causing dependencies between tests (verify() checks with Mockito don't work as expected and behave differently depending on the test order).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.