question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AnnotationSpec: Exception in project-level `TestListener`'s `beforeSpec` causes all test cases to be silently not run

See original GitHub issue

I 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:

  1. I’m writing a new AnnotationSpec test, utilizing @Mock and @InjectMock to provide dependencies I need.
  2. But I forget to @Mock-inject something and Mockito cannot construct the @InjectMock-annotated object and throws InjectMocksException from the initMocks().
  3. 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:closed
  • Created 3 years ago
  • Comments:23 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
sksamuelcommented, Jun 20, 2020

4.0.7 has been released.

On Tue, 16 Jun 2020 at 22:53, Stephen Samuel (Sam) sam@sksamuel.com wrote:

We can do 4.0.7 yes.

Also please let us know what issues you’re having with the plugin and 4.1.

On Tue, 16 Jun 2020, 22:37 Andrey Bolduzev, notifications@github.com wrote:

Hi @andrey-bolduzev https://github.com/andrey-bolduzev That fix was released 4.1.0-RC1 few days back. You can use latest 4.1.0-RC2.

Yep, I know it’s fixed in the 4.1 branch but the adoption of the kotest intellij plugin is not going too well in my team, I am having a hard time getting it to work in a complex project myself. I was going to raise an issue in the plugin repo once I figure out what exactly is happening. But in the meantime, I was hoping another small 4.0 release could be made since the work to cherry-pick the change was done already anyway if I’m not mistaken.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest/issues/1426#issuecomment-645127409, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGWPFUF6TEHBRRYFALDRXA26FANCNFSM4MVVR7SA .

1reaction
ashishkujoycommented, May 16, 2020

@andrey-bolduzev The bug is now fixed in master.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found