Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory

Some of these steps can be found here, but in the end the problem remained.

268565 次浏览

So, I tried all sorts of things to get this to work. I tried "git.path": "/usr/bin/git", adding git directly to my path, etc. Nothing worked.

See also my video that shows Java 9 and JUnit 5 in Eclipse Oxygen.1a in action

Finally, I realized that in my VSCode workspace settings, I had "git.enabled: false". I changed it to true, and it works like a charm.

I have the same issue with STS 3.9.1. It seems like an Eclipse bug, however, to fix this you can add a test dependency junit-platform-launcher to your project (https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher)

rg.junit.platform/junit-platform-launcher)

This is how I did for my project which uses gradle:

dependencies {
// other stuff here


testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "5.${junit5MinorVersion}"
testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: "1.${junit5MinorVersion}"
}

This is how I did for my project which uses gradle:

dependencies {
// other stuff here


testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "5.${junit5MinorVersion}"
testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: "1.${junit5MinorVersion}"
}

gradle.properties file:

junit5MinorVersion=1.0

gradle.properties file:

junit5MinorVersion=1.0

I believe the same applies if you see this exception while using IntelliJ IDEA.

I believe the same applies if you see this exception while using IntelliJ IDEA.

Using STS 3.9.1 I got the same problem. However, currently I do not require any new JUnit5 features, so I tried to force using an older version. If using maven, you can add following dependencies to your pom.xml:

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
<scope>test</scope>
</dependency>
>${junit.vintage.version}</version>

This did the trick for me (at least as long as I do not need JUnit5 explicitly).

Raised an issue for this and commented the same findings. Can be found here https://github.com/Microsoft/vscode/issues/49469

Here's what worked for me:

    Answers so far did not adress the problem of sharing code with other people who don't necessarily use Eclipse. Here is one proposition. The key is to use a maven profile to solve the Eclipse Case.

  1. I uninstalled VS Code
  2. It assumes you have defined a property junit5.version in your pom like:

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit5.version>5.1.1</junit5.version>
    </properties>
    
  3. I deleted C:\Users\myusername\AppData\Roaming\Code
  4. then in the profiles section add the following:

    <profiles>
    <profile>
    <id>eclipse</id>
    <dependencies>
    <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    </dependency>
    <dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-launcher</artifactId>
    </dependency>
    </dependencies>
    <dependencyManagement>
    <dependencies>
    <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>${junit5.version}</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-launcher</artifactId>
    <version>1.1.1</version>
    <scope>test</scope>
    </dependency>
    </dependencies>
    </dependencyManagement>
    </profile>
    </profiles>
    
  5. Re-installed VS Code

All you have to do after this is to select the profile in your local Eclipse: Right click on your project and select Maven > Select Maven Profiles... (or hit Ctrl + Alt + P), and then check the "eclipse" profile we just created.

Selection Of Maven Profile

ofile to solve the Eclipse Case.

With that you are done. Your Eclipse will run Junit 5 tests as expected, but the configuration you added won't pollute other builds or other IDE

It assumes you have defined a property junit5.version in your pom like:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit5.version>5.1.1</junit5.version>
</properties>

I fixed the issue by right clicking the test and selecting 'Run Configurations' and changing the "Test runner:" selection to 'JUnit 4' as shown here:

Screenshot of run configruations

then in the profiles section add the following:

<profiles>
<profile>
<id>eclipse</id>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>

I ran the test again and it worked.

They need to be public.

I found that VScode stopped tracking after I checked out a different branch (new one).

Same error i faced in eclipse version Oxygen.3a Release (4.7.3a) . There is issue in Maven Dependencies mismatch.To solve i have updated my Pom.xml with following dependecies.

What solved it was simply:

  • Closing the working folder.
  • http://maven.apache.org/xsd/maven-4.0.0.xsd">

  • Reopening the folder.
4.0.0 com.netapp.junitnmactiopractice JunitAndMactioPractice 0.0.1-SNAPSHOT

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.jupiter.version>5.1.1</junit.jupiter.version>
<junit.platform.version>1.1.1</junit.platform.version>
</properties>


<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>


<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

VSC then synced with the new branch and showed the differences.

Solution For Mac Users

This is simple way and this way has been solved my problem on Mac:

1) Run this command on console :

sudo xcodebuild -license accept

2) Close Visual Studio Code and reopen it.

As per comment by Alexander Wessel you can use org.junit:junit-bom as described in his answer to question Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory.

That's it.

Note : If you are using MacOS and you have updated your Xcode recently, you may need to accept XCode's terms of service agreement to use git.

Since it's not possible to post code blocks into comments here's the POM template I am using in projects requiring JUnit 5. This allows to build and "Run as JUnit Test" in Eclipse and building the project with plain Maven.

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>


<groupId>group</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project name</name>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.3.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>


<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<!-- only required when using parameterized tests -->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
ache.org/POM/4.0.0"

You can see that now you only have to update the version in one place if you want to update JUnit. Also the platform version number does not need to appear (in a compatible version) anywhere in your POM, it's automatically managed via the junit-bom import.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

As everyone informed it's IDE bug, I tried in Eclipse and STS. In both the cases, it is failing.

As a workaround, I have fixed by modifying the pom.xml file like below.

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

I have added these two maven dependencies junit-jupiter-engine and junit-platform-launcher.

<modelVersion>4.0.0</modelVersion>

pom.xml

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>


<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform launcher -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<groupId>group</groupId>

Also please make sure to add the version of both the maven dependencies in the properties tag.

<properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.2.0</junit-jupiter.version>
<junit-platform.version>1.2.0</junit-platform.version>
</properties>
<artifactId>project</artifactId> <version>0.0.1-SNAPSHOT</version>

None of the solutions helped:

The problem is that Eclipse 2018-12 has support for JUnit 5.3.1. If you start it with a version before that, it will fail.

<name>project name</name>

So make sure you use at least 5.3.1.

<dependencyManagement> <dependencies>

5.4.0 does work too.

<dependency> <groupId>org.junit</groupId> <artifactId>junit-bom</artifactId>

In case your parent pom is Spring Boot, you need to make sure (in dependency management) that junit-jupiter-api is set to the same version. You don't need junit-platform-runner or -launcher!

In my case, the problem was myself and no IDE like Eclipse. I've imported the JUnit 4 Test class.

<version>5.3.1</version>

So do NOT import this one:

import org.junit.Test  // JUnit 4

But DO import that one:

import org.junit.jupiter.api.Test // JUnit 5
<type>pom</type>

Add in your POM:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.3.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<scope>import</scope>

Adding this maven dependency with JUnit Jupiter (v.5.5.1) solves the issue.

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
</dependency>

From the start the error message tell you that class is not found : NoClassDefFoundError that mean the PATH to junit is the problem.

    </dependencies>
  1. Press right click to project folder and choose Properties OR select project folder and press combination cmd + i.

  2. </dependencyManagement> <dependencies>
  3. select from list "Java Build Path".

  4. <dependency>
  5. select "Libraries" tab
  6. <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <scope>test</scope> </dependency>
  7. If JUnit 5(or JUnit 4) is added to "Modulepath", select the "JUnit 5" and press Remove.
  8. select "Classpath", press "Add Library...".
  9. from opened "Add Library" window, select JUnit, press next.
  10. Select JUnit library version that you need and press Finish.

That is all. Try to run test again.

<dependency> <groupId>org.junit.platform</groupId>

I am using eclipse 2019-09.

<artifactId>junit-platform-launcher</artifactId>

I had to update the junit-bom version to at least 5.4.0. I previously had 5.3.1 and that caused the same symptoms of the OP.

<scope>test</scope>

My config is now:

    <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.5.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

You can use only junit-jupiter as a test dependency instead of junit-jupiter-api, junit-platform-launcher, junit-jupiter-engine.

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependency>

you should change

@Test
public static void testmethod(){}
<dependency>

to

@Test
public void testmethod(){}
<!-- only required when using parameterized tests -->

the @Test is unsupport static method

<groupId>org.junit.jupiter</groupId>

For me, I configured the build path to add JUnit 5 Library and also by adding the dependency

     <dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<artifactId>junit-jupiter-params</artifactId> <scope>test</scope>

seperately.

</dependency>

I ran into the same error, and in my case it was a simple matter of going to Project Properties > Maven > Update project and/or cleaning and rebuilding the project.

Java version: 1.8.0_191

and the message displayed is

Adding another solution in case someone like me runs in to this again.

No tests found with test runner 'JUnit5'

what worked for me was the configuration below

    <properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<junit-platform.version>1.5.2</junit-platform.version>
</properties>


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
Right click to project -> New -> Other -> JUnit -> JUnit Test Case

For me, the solution was (on Mac) Code > Settings > User Settings > Extensions > Git

o Enabled - Whether git is enabled.

Git enabled setting

esourceGroup": true,

Tested in VsCode on Windows dev PC.

"git.autofetch": true,

What worked for me was to enter Settings by hitting Ctrl + , "git.path": "D:\\program files\\Git\\bin\\git.exe" at least on my machine and then enter the following setting: } SCM.provider.AlwaysShowProviders

and

Then just ticked the checkbox and Git was lighting up again and I could then go to Source Control by Ctrl+shift+G.

1.4.1 works in my setup.

I think this is a bug in eclipse as it is working with higher version libraries of junit and not other version.

You need initialize (git init in terminal) your project/folder, that your VS Code to be able to see his as git-project.

This resolved my issue. The other resolution looked less feasible or risky to me.

Enter in your project/folder through terminal

cd ~/ImbaFolder
git init (it created .git file - the git repository)
Thanks.

When I change my jupiter api version into latest one, it was solved. Meanwhile, my eclipse and other eclipse extensions ide's (such as STS) is getting build path error. For every maven update, ide forces me to set the JRE System Library.

My plugin was disabled, just enabled it.

  1. Go to extension(click on the extension icon on the left),
  2. li>

I use actually spring-tool-suite-4-4.5.1 and I had this bug when I want run a test class.

  • Serach for @builtin git,
  • Enable the git default built in extension,
  • and the solution was to add to 'java build path', 'junit5' in Libraries

    enter image description here

    its easy to set up your git account and start using it.

    I see that Cygwin isn't mentionned here. It happened to me and I found the solution https://github.com/Microsoft/vscode/issues/7998#issuecomment-245356777.

    Now, restart VSCode

    If you are using Git from Cygwin.From Windows terminal, execute the following command :

    > cd c:\
    > md cygdrive
    > cd cygdrive
    > c:\ - mklink /j "c" c:\
    

    You are missing JUnit 5 platform launcher with group: 'org.junit.platform', name: 'junit-platform-launcher'

    (Assuming that git is stored in the following folder : C:\Cygwin\bin\git.exe)

    Just add in ur POM:

    <dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-launcher</artifactId>
    </dependency>
    
    ef="https://i.stack.imgur.com/pTxMe.png" rel="nofollow noreferrer">VS Code Keep Source Control

    This panel will remain blank - by design apparently. Even after installing GIT and VS Code finding it, nothing will be shown here. No need to install other extension, as GIT extension (now) comes default with VS Code. I only install Windows GIT, which VS Code will find as long as it's in the PATH.

    ioncontrol#_git-support

    You need to manually add repositories to populate this window.

    "You can clone a Git repository with the Git: Clone command in the Command Palette (Ctrl+Shift+P). (edit: Type in 'git: clone' in the command box) You will be asked for the URL of the remote repository"

    https://code.visualstudio.com/docs/editor/versioncontrol#_git-support

    I hope this helps someone as there is so much confusion about this. MS should really improve how this behaves for a more consistent user experience - which they may well do at some point.

    Later I created a new JUnit Class from New -> Junit TC. Copied the same code. It works fine and error vanished.

      e reason that Git controls are hidden until there is a workspace where a new repo can be initialized.

      ir download page for windows. https://git-scm.com/download/win

    1. If SCM view is empty you need to install a source code provider.

    2. After installing you’ll see Git Extensions for VS Code listed under Extensions view. Select it and click install on the right hand side panel that appears.

    3. Check Extensions (Ctrl+Shift+X) under View and select the SCM provider you want. Start typing @ca and you will see extensions listed. Select @category: “scm providers” to see available SCM providers.

    4. After installing the SCM remember to close and reopen VS Code.

  • If you don’t see Git here you need to install Git. Here’s their download page for windows. https://git-scm.com/download/win

  • This issue happening while implementing Mockito with spring boot api. Below add below dependency in in gradle file

    compile group: 'org.mockito', name: 'mockito-core', version: '2.22.0'
    
  • After installing you’ll see Git Extensions for VS Code listed under Extensions view. Select it and click install on the right hand side panel that appears.

  • Note: Spring boot version 2.2.0

    Try to reconfigure your unit test configurations to be the project JRE. enter image description here

      I just fixed this problem. I newly installed VS Code and this problem occurs.

    1. Edit the setting file, set the gitpath to /usr/bin (my git dir)
    2. OS: Ubuntu 18.04.2

    3. Run git init command in my project folder
    4. On my source control tab, it shows "no source control providers registered".

    5. Press ctrl+shift+P and run "reload window" command

    And this problem is fixed.

    Here's how I fixed this problem.

      I had a similar issue. It was due to an incorrect source path in properties.

    1. Edit the setting file, set the gitpath to /usr/bin (my git dir)
    2. Open project properties -> Java Build Path -> Sources. And remove the incorrect path if it is your case

  • Run git init command in my project folder
  • adding org.junit.platform to your pom and build it. Next, you need to go to "Run Configuration" of your TEST FILE and add JUNIT in the classpath, APPLY->RUN will resolve the issue.

  • Press ctrl+shift+P and run "reload window" command
  • I got the same problem in a SpringBoot project and, in my case, the cause was that the ouput folder '/target/test-classes' was empty.

    And this problem is fixed.

    Fixed it manually in the .classpath file, looking for the classpathentry with the attribute "test" and changing the content of the output attribute:

    "/>

    From this:

    <classpathentry kind="src" output="<project folder>/target/test-classes" path="src/test/java">
    <attributes>
    <attribute name="test" value="true"/>
    <attribute name="optional" value="true"/>
    <attribute name="maven.pomderived" value="true"/>
    </attributes>
    </classpathentry>
    
    <attribute name="optional" value="true"/>

    to this:

    <classpathentry kind="src" output="target/test-classes" path="src/test/java">
    <attributes>
    <attribute name="test" value="true"/>
    <attribute name="optional" value="true"/>
    <attribute name="maven.pomderived" value="true"/>
    </attributes>
    </classpathentry>
    

    You might be importing @Test from org.junit.Test, which is a JUnit 4 annotation. The Junit5 test runner will not discover it.

    The reason for this problem is that Git is not initialized in the folder that you are trying VS Code to open (this is for Windows 10).

      The Junit5 test runner will discover a test annotated with org.junit.jupiter.api.Test

    • Install Visual Studio Code from https://code.visualstudio.com/download
    • Found the answer from Import org.junit.Test throws error as "No Test found with Test Runner "JUnit 5""

      it will look like this C:\Users\YourName\git (<-- you can pick any directory)
    • Install Git from https://git-scm.com/
    • While you are in that folder, right-click > Git GUI Here > Create New Repository
    • Create a folder named git in: C:\Users\YourName\ so it will look like this C:\Users\YourName\git (<-- you can pick any directory)
    • In pop-up window Browse for the folder you just created (to initialize Git there) > click Create
    • While you are in that folder, right-click > Git GUI Here > Create New Repository
    • This will create a .git file in that folder
    • In pop-up window Browse for the folder you just created (to initialize Git there) > click Create
    • Open VS Code > File > Open Folder > (select the folder you just initialized Git at)
  • This will create a .git file in that folder
  • Removing the JUnit library, and then adding it again fixed this issue for me.

    replace:

    import org.junit.Test;
    

    Scenario: For MAC + issue afer installing/updating xcode:

    with:

    import org.junit.jupiter.api.Test;
    

    Can also happen when you install xcode and yet to accept the license terms. To accept the terms, just run the below.

    >xcode and yet to accept the license terms. To accept the terms, just run the below.

    sudo xcodebuild -license

    sudo xcodebuild -license

    Post to this restart VS code & you are good to go.

    You should make sure your test case function is public rather than private to make it accessible by Test Runner.

    @Test
    private void testmethod(){}
    

    Since i installed GIT in custom defined path, i needed to reference it inside settings.json

    to

    @Test
    public void testmethod(){}
    

    ( F1 > settings.json > enter )

    case made it look like:

    {
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "git.path": "<custom path to git.exe>"
    }
    

    Add setting:

    "git.path": "<custom path to git.exe>"
    

    Right after it worked perfectly.

    Wich in my case made it look like:

    {
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "git.path": "<custom path to git.exe>"
    }
    

    Converting the Java project to Maven Project fixed the issue for me. The conversion was done on Eclipse by: Right Click Project -> Configure -> Convert to Maven Project

    ension was disabled!!

    screencapture

    In my case the Git was installed on my machine, VSCode->settings->Git was enabled, path to git.exe was set, even then it was showing me the same error i.e. "No source control providers registered."

    that message went away.

    >Git Clone
    

    Finally by running the following command from "Command Palette" I was able to clone my repository and that message went away.

    >Git Clone
    

    I got the idea of above command from following VSCode online documentation.

    So I tried nearly every answer and nothing.

      However, JUnit 5 which is the Jupiter 5.7.0 version (and this is the one that comes with eclipse not a separate mvn dependency I added to my project) when run is actually looking in a different folder than I specified, this being target/test-classes. If I manually move my class files from the Output Folder folder that I specified to the target/test-classes folder, then my unit tests will run.

    • Re-install Git
    • So make sure that your class files are in the location that the runtime thinks they should be in.

  • Initialize an empty repository locally with git init
  • Checked to make sure the @builtin git was enabled
  • Change it to JUnit 4 And its works. Please try it (If you have simple example then definatlty try this.) Click on that class file --> It will come Run/Debug Settings ---> Click on new --> Select JUnit --> Click on okay --> Change TestRunner into Junit 4. And Click on apply and okay. And then run It will work for sure.

    In my case, I had used beforeAll without static key and then i used static key for method signature and my problem was solved.