Junit Eclipse Error: "No test found with test Runner Junit 5"

Asked

Viewed 2,567 times

4

I’m not being able to run my tests in Eclipse, below is a simple test that doesn’t work:

import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class TesteTest {

    @BeforeEach
    void setUp() throws Exception {
    }

    @Test
    void test() {
       Assert.assertTrue(true);
   }

}

Error message: No test found with test Runner Junit 5

Run Configurations:

inserir a descrição da imagem aqui

Source: inserir a descrição da imagem aqui

Libs:

inserir a descrição da imagem aqui

  • what you want to test basically? There is no Class?

  • In this piece of code I am not testing any class, this example is just to test Junit, any test I do I get this same error message!

  • If you do not want to use Junit 5, there in the "Test Runner" field select "Junit 4".

  • There’s new way on how to configure your test with Junit 5 Explained on https://www.eclipse.org/community/eclipse_newsletter/2017/october/article5.php

2 answers

0

if you’re trying with junit 5, you put @Runwith(Junitplatform.class)

imports org.junit.Platform.runner.Junitplatform; because then eclipse recognizes junit test classes as test classes

  • I put the note in the class but the error continues, there is something beyond that to do?

  • @Pedrohenrique which version of the java and eclipse you are using

  • Eclipse IDE for Enterprise Java Developers. Version: 2018-12 (4.10.0) and Java 8 (1.8)

  • @Pedrohenrique Putz, I believe you’ve fallen for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=537470, take a look and see if that’s right

0

1- Check that you have the Junit dependency on your project’s classpath. This is usually declared in pom.xml (Maven) or build.Gradle (Gradle)

1.1 If you are a Gradle project, this instruction has solved my problem before:

dependencies {
  testImplementation 'junit:junit:<x.y>'
}

test {
  useJUnit()

}

1.2 If you are Maven, there are some guides for setting up, kind of like that

Browser other questions tagged

You are not signed in. Login or sign up in order to post.