Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ParameterizedTest gets executed before @Before function

why parameterized tests are executed before setUp function?

    @Before
    public void setUp(){
        System.out.println("some logic");
    }


    @ParameterizedTest
    @CsvSource({"1997"})
    void myTest(String arg) {
        System.out.println(arg);
    }
like image 304
kingGarfield Avatar asked Oct 24 '25 03:10

kingGarfield


1 Answers

Relating to @aeberhart's comment, there is no @Before annotation in JUnit 5, if that's what you're using as a test runner. You need to use @BeforeAll, which in is the same as JUnit 4's @BeforeClass.

like image 86
tomdaly Avatar answered Oct 26 '25 17:10

tomdaly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!