AnnotationSpec: Exception in project-level `TestListener`'s `beforeSpec` causes all test cases to be silently not run
See original GitHub issueI have a project that uses Mockito for mocking. The project config looks something like this:
object KotestConfig : AbstractProjectConfig() {
override val isolationMode: IsolationMode? = InstancePerLeaf
override fun listeners(): List<TestListener> = listOf(MockitoInjectListener)
}
private object MockitoInjectListener : TestListener {
override suspend fun beforeSpec(spec: Spec) {
MockitoAnnotations.initMocks(spec)
}
}
The situation is as follows:
- I’m writing a new
AnnotationSpec
test, utilizing@Mock
and@InjectMock
to provide dependencies I need. - But I forget to
@Mock
-inject something and Mockito cannot construct the@InjectMock
-annotated object and throwsInjectMocksException
from theinitMocks()
. - From what I can see this makes the chain in
InstancePerLeafSpecRunner#executeInCleanSpec
fall through without executing the test cases but also without reporting its failure to do so. So when running all tests in the project, the developer assumes that everything is passing.
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (15 by maintainers)
Top Results From Across the Web
Tests not running in Test Explorer - visual studio
I have been working with the resharper test runner - which works fine. All tests are running, all tests are showing the right...
Read more >Grouping Tests with Tags - Kotest
MyTestClass is instantiated in order to retrieve the tags defined in the class. The beforeSpec callback is not executed because there are no...
Read more >Beware silently skipped tests in Mocha - Adam Coster
Any Mocha.js tests defined within an async describe function will be silently skipped! (Don't use async functions in your describe() callbacks.)
Read more >Set permissions and access for manual testing - Azure DevOps
How to grant or restrict access to test plans, test suites, test cases, and other test-related features.
Read more >Documentation - TestNG
@AfterTest: The annotated method will be run after all the test methods ... If no exception or a different than one on this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
4.0.7 has been released.
On Tue, 16 Jun 2020 at 22:53, Stephen Samuel (Sam) sam@sksamuel.com wrote:
@andrey-bolduzev The bug is now fixed in master.