fair-acc / chart-fx

A scientific charting library focused on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points.
GNU Lesser General Public License v3.0
488 stars 90 forks source link

FXUtils.assertJavaFxThread() fails with @ParametrizedTest #543

Open MarsBlessed opened 1 year ago

MarsBlessed commented 1 year ago

Describe the bug FXUtils.assertJavaFxThread() fails when run in a parametrized unit test

To Reproduce try these tests:

@ExtendWith(ApplicationExtension.class)
@ExtendWith(JavaFxInterceptor.class)
public class ParametrizedExampleTest {
    @Start
    public void start(Stage stage) {
        stage.setScene(new Scene(new StackPane(), 120, 200));
        stage.show();
    }

    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    public void test(boolean value) {
        FXUtils.assertJavaFxThread();
    }
}
@ExtendWith(ApplicationExtension.class)
@ExtendWith(SelectiveJavaFxInterceptor.class)
public class ParametrizedExampleTest {
    @Start
    public void start(Stage stage) {
        stage.setScene(new Scene(new StackPane(), 120, 200));
        stage.show();
    }

    @TestFx
    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    public void test(boolean value) {
        FXUtils.assertJavaFxThread();
    }
}

Environment:

MarsBlessed commented 1 year ago

it is not a blocker so far but duplicating the test code doesn't look quite good when it could be done using @ParametrizedTest

MarsBlessed commented 1 year ago

Note also that in the second example @TestFx forces the test to run one extra time with ParameterResolutionException: No ParameterResolver registered