java.lang.Exception: No tests found matching Method using Intellij IDEA

后端 未结 12 2179
说谎
说谎 2020-12-14 14:12

I am experiencing a strange behavior of Intellij IDEA 2016.3. Having a class with method foo and a JUnit test for the method when I get java.lang.Exceptio

相关标签:
12条回答
  • 2020-12-14 14:46

    This situation can also occur if you do not place @Test annotation above the test method.

    0 讨论(0)
  • 2020-12-14 14:48

    Deleting Intellij's out directory fixed this issue for me.

    0 讨论(0)
  • 2020-12-14 14:48

    Maybe you just give a wrong name for test method.

    I met this problem because I used '—' instead of '_' which intelliJ cannot represent.

    0 讨论(0)
  • 2020-12-14 14:50

    Make sure you've correct runner mentioned above your class.

    I was getting this weird message when I was using runner CucumberWithSerenity.class. When I changed to SerenityRunner.class it got fixed.

    @RunWith(SerenityRunner.class)
    //@RunWith(CucumberWithSerenity.class)
    public class WordPressAppTest {
    

    I'm using Serenity framework for web automation and use below runner class

    import net.serenitybdd.cucumber.CucumberWithSerenity;
    import net.serenitybdd.junit.runners.SerenityRunner;
    import org.junit.runner.RunWith;
    

    I feel IDEA ( 2017.2.6 ) can show some better error message than this

    0 讨论(0)
  • 2020-12-14 14:54

    Make sure that your @test methods as well as the test class are public.

    0 讨论(0)
  • 2020-12-14 14:55

    If you originally run a test named "foo", and then rename it to "fooBar", you must subsequently run "fooBar" with a new Run Configuration.

    If you use the same original Run Configuration for "foo" to run "fooBar", it still looks for a test named "foo" which it does not find (thus the Exception) because it was renamed to "fooBar". The new Run Configuration would correctly look for "fooBar" test.

    I made this mistake unknowingly because I renamed a test, but then just clicked the green run button in IntelliJ: Doing that runs the last Run Configuration, which in this scenario has the old "foo" name.

    0 讨论(0)
提交回复
热议问题