import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
public class SampleTest {
@Test
public void testMyMethod1() {
System.out.println("write this");
}
@Nested
class NestedClass {
@Test
public void testMyMethod2() {
System.out.println("nested write 2");
}
}
@Nested
class NestedClass2 {
@Test
public void testMyMethod1() {
System.out.println("nested write 1");
}
@Test
public void testMyMethod3() {
System.out.println("nested write 3");
}
@Nested
class DoubleNestedClass3 {
@Test
public void testMyMethod4() {
System.out.println("double nested write 4");
}
@Test
public void testNextedException() throws Exception {
throw new Exception();
}
}
}
}
we have two major issues:
The "Test Results" window shows only some of the executed tests (in this specific case only 3)
using the "Run focused test method" does not work - a bad combo of class and method is provided to the test runner.
Did some root-cause analysis too. The issue with Tests not showing is caused by the fact that the whole testrunner support was made with the assumption that test suites are executed sequentially. This, unfortunately is not true with nested tests, where the execution may look like
A$B.method1
A.method2
A$B.method3
A.method4
Fixing this needs significant changes to TestSession and TestProgressListener which assume that only one suite can be running at any given time (and thus measures the elapsed time).
It works somewhat if tests are only on equal level, e.g.
A$B.method1
A$B.method2
A$C.method3
A$C.method4
If there was a method directly on A, like A.otherMethod, then the results would not be shown again.
Use case/motivation
Work with such classes without issues
Related issues
No response
Are you willing to submit a PR?
[x] Yes I am willing to submit a PR!
Code of Conduct
[X] I agree to follow the Apache Software Foundation's Code of Conduct
Description
original ticket: https://issues.apache.org/jira/browse/NETBEANS-6041
Given a test class like:
we have two major issues:
Did some root-cause analysis too. The issue with Tests not showing is caused by the fact that the whole testrunner support was made with the assumption that test suites are executed sequentially. This, unfortunately is not true with nested tests, where the execution may look like
Fixing this needs significant changes to
TestSession
andTestProgressListener
which assume that only one suite can be running at any given time (and thus measures the elapsed time).It works somewhat if tests are only on equal level, e.g.
If there was a method directly on A, like A.otherMethod, then the results would not be shown again.
Use case/motivation
Work with such classes without issues
Related issues
No response
Are you willing to submit a PR?
Code of Conduct