All links of one day
in a single page.
<Previous day - Next day>

rss_feedDaily RSS Feed
floral_left The Daily Shaarli floral_right
——————————— October 15, 2020 - Thursday 15, October 2020 ———————————
Test - Paramétré - JUnit - Jupiter - DataProvider -

Comment utiliser un data provider avec JUnit 5.

Dépendance maven :

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>

Pour le reste, le data provider s'écrit comme pour TestNG, mais sans l'annotation @Dataprovider. Exemple :

public static Object[][] sumTestData() {
        return new Object[][]{
            {2, 2, 4},
            {10, 1, 11},
            {1000000, -1000000, 0}
        };
}

Et on utilise le data provider ainsi :

@ParameterizedTest
@MethodSource("sumTestData")
public void dataProviderTest(int a, int b, int expectedSum) {
    Assertions.assertEquals(expectedSum, a + b);
}
-