Use the @TestInstance annotation
This commit is contained in:
@ -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()}
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user