简体   繁体   中英

TestNG @Factory analog in JUnit 5

In TestNG we can annotate test class constructor @Factory annotation and specify data provider for this factory like this:

@Factory(dataProvider = "dataProviderName")

And TestNG create instance of test class for each object returned by data provider. In JUnit 5 I didn't found feature exactly like that. My question is, how I can reproduce that behavior in JUnit 5?

Thanks in advance for your help

Please, read a guide about Dynamic tests - https://junit.org/junit5/docs/current/user-guide/#writing-tests-dynamic-tests-examples

Also, dynamic tests can be parameterized (like data providers) with Sources - https://junit.org/junit5/docs/current/user-guide/#writing-tests-dynamic-tests-uri-test-source read this part of guide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM