Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No test are shown when all tests passed with forked unit tests #7710

Open
Eccenux opened this issue Aug 29, 2024 · 6 comments
Open

No test are shown when all tests passed with forked unit tests #7710

Eccenux opened this issue Aug 29, 2024 · 6 comments
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix Maven [ci] enable "build tools" tests tests

Comments

@Eccenux
Copy link

Eccenux commented Aug 29, 2024

Apache NetBeans version

Apache NetBeans 22

What happened

I have some unit tests (org.junit.jupiter.api.Test). I execute tests, but when they are all OK (all passed) the I see status which indicates no testes where execute at all:
obraz

Only when I go to Output tab I can see:

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

Language / Project Type / NetBeans Component

Java Maven Spring application

How to reproduce

  1. Create jupiter unit test file.
  2. Add testFail.
  3. Execute file: CTRL+F6.
  4. -> "4 tests passed, 1 test failed" (OK)
  5. Fix (uncomment fix).
  6. Execute file: CTRL+F6.
  7. -> "No tests executed" (bug)

Example test failing.

	@Test
	void testFail() {
		String input = "abc";
		String expected = "123";
//		// fix
//		input = expected;
		assertEquals(expected, input);
	}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

@Eccenux Eccenux added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Aug 29, 2024
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) tests labels Aug 29, 2024
@mbien
Copy link
Member

mbien commented Aug 29, 2024

you are saying if you run this, the window will say no tests executed? Can you try to reproduce this in a new project?

import org.junit.jupiter.api.Test;

public class Mavenproject1Test {
    @Test
    public void test1() {
    }
    @Test
    public void test2() {
    }
}

its working for me. Tested with junit.jupiter 5.11.0.

@Eccenux
Copy link
Author

Eccenux commented Aug 31, 2024

Interesting... I cannot reproduce it in a small, new project either... But I also have no idea where I should look for problems in the bigger project? I know the big project works fine in IntelliJ.

The test section of the output looks pretty much the same:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running pl.enux.maventestproject.JupiterNbTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.052 s -- in pl.enux.maventestproject.JupiterNbTest

Results:

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

The big project:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running pl.mol.molnet.opac.search.SlugTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 s -- in pl.mol.molnet.opac.search.SlugTest

Results:

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

Does NetBeans check the output to determine which tests passed, or does it use something else?

@matthiasblaesing
Copy link
Contributor

@Eccenux if I remember correctly the code you are looking for is here:

https://github.com/apache/netbeans/blob/master/java/maven.junit/src/org/netbeans/modules/maven/junit/JUnitOutputListenerProvider.java

The code uses a combination of "listening" to the output and reading the surefire/failsafe XML outputs. If the stdout output looks identical, the assumption would be, that the XML outputs are not at the expected location or maybe surpressed?

@mbien
Copy link
Member

mbien commented Sep 4, 2024

@Eccenux would you like to give this dev-build a try https://github.com/apache/netbeans/actions/runs/10692992128/artifacts/1888805200?

this is addressing an issue with multi-module builds and the test window - maybe we are lucky and it fixes your problem too.

@Eccenux
Copy link
Author

Eccenux commented Sep 5, 2024

Dev build didn't help. But I was able to reproduce.

Here is my small test project with which you should be able to reproduce the problem (also in the dev build):
https://github.com/Eccenux/MavenTestProject/blob/master/pom.xml#L74

It's a problem with <tests.unit.forkCount>2</tests.unit.forkCount>. When modified to 1 fork it works as expected, 2 forks and it brakes.

@Eccenux Eccenux changed the title No test are shown when all tests passed No test are shown when all tests passed with forked unit tests Sep 5, 2024
@mbien
Copy link
Member

mbien commented Sep 5, 2024

@Eccenux thanks for testing and the info! I suspected that it might be due to fork or other concurrency related problems (parallel build or mvnd).

The detection for this situation is not very good right now, it will also fail if the config for this is in the parent pom.

I am wondering if we should try a different approach there, e.g adding a file watch to the folder instead of delaying the check for the xml files.

@mbien mbien added Maven [ci] enable "build tools" tests and removed needs:triage Requires attention from one of the committers labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix Maven [ci] enable "build tools" tests tests
Projects
None yet
Development

No branches or pull requests

3 participants