Java with Ant - JUnit Bug
Apache NetBeans version
Apache NetBeans 23
What happened
I created a simple unit test, but it generates the following error when running the test:
/home/ajvelez/.cache/netbeans/23/executor-snippets/junit.xml:184: The following error occurred while executing this line:
/home/ajvelez/.cache/netbeans/23/executor-snippets/junit.xml:128: The
Language / Project Type / NetBeans Component
Java / Java with Ant / JUnit execute
How to reproduce
Create a Java with Ant y execute the next test
public class NewEmptyJUnitTest {
public NewEmptyJUnitTest() { }
@Test
public void hello() {
assertEquals(20, 20);
}
}
Did this work correctly in an earlier version?
No / Don't know
Operating System
Fedora 40
JDK
JDK17 and JDK22
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
No response
Are you willing to submit a pull request?
No
Where is the reproducer for the problem?
Create a Java with Ant project, and execute the next test.
public class NewEmptyJUnitTest {
public NewEmptyJUnitTest() { }
@Test public void hello() {
assertEquals(20, 20);
}
}
@antoniojvelezq you could have simplified this by just providing the project. Anyway, yes, the projects seems to be incorrectly generated, as JUnit 5 is put onto the classpath.
The following scenario reproduces the error.
New Project -> Java with Ant -> Java Application. choose location and name.
generated by my choices
package puk;
public class Puk {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
Add test for existing class. Generated is a test class with references to junit 5:
package puk;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class PukTest {
public PukTest() {
}
@Test
public void testSomeMethod() {
fail("puk");
}
}
The libraries are loaded, fitting to this choice of junit.
However, trying to run the test produces
It appears that the build-impl.xml is not prepared to use junit 5 tests.