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

No tests found #23

Closed
elect86 opened this issue Jun 1, 2022 · 6 comments · Fixed by #24
Closed

No tests found #23

elect86 opened this issue Jun 1, 2022 · 6 comments · Fixed by #24

Comments

@elect86
Copy link

elect86 commented Jun 1, 2022

as titled, fresh cloned, tried to run the test(s) via Idea gui:

Execution failed for task ':test'.
No tests found for given includes: [org.example.detekt.MyRuleSpec](--tests filter)
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

If I switch to running test with Idea instead:

org.junit.runners.model.InvalidTestClassError: Invalid test class 'org.example.detekt.MyRuleSpec':

  1. Test class should have exactly one public zero-argument constructor

at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
at org.junit.runners.ParentRunner.(ParentRunner.java:102)
at org.junit.runners.BlockJUnit4ClassRunner.(BlockJUnit4ClassRunner.java:84)
at org.junit.runners.JUnit4.(JUnit4.java:23)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Process finished with exit code 255

@BraisGabin
Copy link
Member

I just cloned the repo and I ran ./gradlew test and it worked. What are you using to run the tests?


at org.junit.runners.JUnit4.(JUnit4.java:23)

That's strange. We use Junit5 on this project, we don't use JUnit4.

@elect86
Copy link
Author

elect86 commented Jun 1, 2022

What about running via Idea gui instead?

However, what output do you see? I have this:

elect@5800x:~/IdeaProjects/detekt-custom-rule-template$ ./gradlew test

BUILD SUCCESSFUL in 865ms
4 actionable tasks: 2 executed, 2 up-to-date

Anyway, if I change the first test in order to make it fail:
assertThat(findings).hasSize(2)
I still see the very same output

@BraisGabin
Copy link
Member

Ooops! Good catch! I can see the error now.

@BraisGabin
Copy link
Member

I found the issue. The import of @Test points to JUnit4 🤦. I didn't expect that truth will import that dependency (google/truth#333). I'm still looking for a good assertion library for kotlin. I like hamscrest but they really heavily on the function is(...) and on kotlin it should be quoted as `is`(...).

@elect86
Copy link
Author

elect86 commented Jun 2, 2022

What about kotest?

@BraisGabin
Copy link
Member

Nice idea: #25

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 a pull request may close this issue.

2 participants