Skip to content

Add Total Run Times #957

@spottedmahn

Description

@spottedmahn

What about adding some totals to the report?

image

It should account for @BeforeAll, @AfterAll, @BeforeEach, @AfterEach

Sidenote: individual test times currently include @AfterAll and I don't think they should. Perhaps I should file a separate issue on that one?

/*
 * This Java source file was generated by the Gradle 'init' task.
 */
package test.times;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class LibraryTest {

    @BeforeAll
    static void beforeAll() throws InterruptedException {
        Thread.sleep(4000); // 4 secs startup
    }

    @AfterAll
    static void afterAll() throws InterruptedException {
        Thread.sleep(3000); //3 secs shutown
    }

    @BeforeEach
    void beforeEach() throws InterruptedException {
        Thread.sleep(1000); // 1 secs for each test
    }

    @AfterEach
    void afterEach() throws InterruptedException {
        Thread.sleep(2000); // 2 secs for each test
    }

    @Test

    void testSomeLibraryMethod() {
        Library classUnderTest = new Library();
        assertTrue(classUnderTest.someLibraryMethod(), "someLibraryMethod should return 'true'");
    }
}
/*
 * This Java source file was generated by the Gradle 'init' task.
 */
package test.times;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class LibraryTest2 {

    @BeforeAll
    static void beforeAll() throws InterruptedException {
        Thread.sleep(1000); // 1 secs startup
    }

    @AfterAll
    static void afterAll() throws InterruptedException {
        Thread.sleep(1000); // 1 secs shutown
    }

    @BeforeEach
    void beforeEach() throws InterruptedException {
        Thread.sleep(1000); // 1 secs for each test
    }

    @AfterEach
    void afterEach() throws InterruptedException {
        Thread.sleep(1000); // 1 secs for each test
    }

    @Test

    void testSomeLibraryMethod() {
        Library classUnderTest = new Library();
        assertTrue(classUnderTest.someLibraryMethod(), "someLibraryMethod should return 'true'");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions