Use the @TestInstance annotation

This commit is contained in:
baislsl
2018-02-08 03:00:55 +08:00
parent e7b119c95c
commit 36f5947cd7
11 changed files with 36 additions and 8 deletions

View File

@ -23,6 +23,7 @@
package com.iluwatar.interpreter;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@ -43,6 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
* @param <E> Type of Expression
* @author Jeroen Meulemeester
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class ExpressionTest<E extends Expression> {
/**
@ -88,6 +90,13 @@ public abstract class ExpressionTest<E extends Expression> {
this.factory = factory;
}
/**
* Create a new set of test entries with the expected result
*
* @return The list of parameters used during this test
*/
public abstract Stream<Arguments> expressionProvider();
/**
* Verify if the expression calculates the correct result when calling {@link E#interpret()}
*/

View File

@ -38,7 +38,8 @@ public class MinusExpressionTest extends ExpressionTest<MinusExpression> {
*
* @return The list of parameters used during this test
*/
public static Stream<Arguments> expressionProvider() {
@Override
public Stream<Arguments> expressionProvider() {
return prepareParameters((f, s) -> f - s);
}

View File

@ -38,7 +38,8 @@ public class MultiplyExpressionTest extends ExpressionTest<MultiplyExpression> {
*
* @return The list of parameters used during this test
*/
public static Stream<Arguments> expressionProvider() {
@Override
public Stream<Arguments> expressionProvider() {
return prepareParameters((f, s) -> f * s);
}

View File

@ -42,7 +42,8 @@ public class NumberExpressionTest extends ExpressionTest<NumberExpression> {
*
* @return The list of parameters used during this test
*/
public static Stream<Arguments> expressionProvider() {
@Override
public Stream<Arguments> expressionProvider() {
return prepareParameters((f, s) -> f);
}

View File

@ -38,7 +38,8 @@ public class PlusExpressionTest extends ExpressionTest<PlusExpression> {
*
* @return The list of parameters used during this test
*/
public static Stream<Arguments> expressionProvider() {
@Override
public Stream<Arguments> expressionProvider() {
return prepareParameters((f, s) -> f + s);
}