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

Get elapsed time reported correctly for @Nested tests #22

Closed
fabriciorby opened this issue Jul 21, 2022 · 3 comments · Fixed by #23
Closed

Get elapsed time reported correctly for @Nested tests #22

fabriciorby opened this issue Jul 21, 2022 · 3 comments · Fixed by #23
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fabriciorby
Copy link
Owner

BTW, the time reported is still not correct because of a reverse order of events the surefire plugin is sending to the ReportConsole

here's an example:

public class NestedWaitingTest {
@Test
public void outside() throws InterruptedException {
    Thread.sleep(1000);
}
@Nested
class Inside1Test {
    @Test
    public void inside1() throws InterruptedException {
        System.out.println("Waiting for 3 seconds");
        Thread.sleep(3000);
    }
    @Test
    public void inside1fast() {
    }

    @Nested
    class Inside2Test {
        @Test
        public void inside2fast() {
        }
    }
}
}

you get this report (without plugin)
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 s - in NestedWaitingTest$Inside1Test$Inside2Test
[INFO] NestedWaitingTest.outside Time elapsed: 1.019 s
[INFO] NestedWaitingTest$Inside1Test.inside1fast Time elapsed: 0.001 s
[INFO] NestedWaitingTest$Inside1Test.inside1 Time elapsed: 3.007 s
[INFO] NestedWaitingTest$Inside1Test$Inside2Test.inside2fast Time elapsed: 0.001 s
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.021 s - in NestedWaitingTest$Inside1Test
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.053 s - in NestedWaitingTest

this translate into 3 events coming into ConsoleReporter
1st one you use today to print the entire data (includes 4 entires in the TreeSetStats) - but uses the elapsed time of the inner*2 test class
2nd and 3rd event are coming without any entries in the TreeSetStats but with correct elapsed time information

so if you want to be consistent with the elapsed time, you need to implement a different approach

Originally posted by @avishayh in #21 (comment)

@fabriciorby fabriciorby changed the title Get time reported correctly for @Nested tests Get elapsed time reported correctly for @Nested tests Jul 21, 2022
@fabriciorby fabriciorby added the help wanted Extra attention is needed label Jul 21, 2022
@fabriciorby fabriciorby self-assigned this Jul 21, 2022
@fabriciorby
Copy link
Owner Author

Ticket created: https://issues.apache.org/jira/browse/SUREFIRE-2111

There is no way of getting other events within the same event

@fabriciorby fabriciorby added the enhancement New feature or request label Jul 21, 2022
@fabriciorby fabriciorby linked a pull request Jul 21, 2022 that will close this issue
@fabriciorby
Copy link
Owner Author

@avishayh
Copy link
Contributor

avishayh commented Jul 24, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants