Java – add setup steps for multiple JUnit test classes

In a project, there are multiple test classes, and each test class contains multiple test methods For example, I want to create a database connection before running each test class Whether I run a single test class, multiple test classes, or test suites, I should establish a connection

Can you propose a design or any JUnit technique to solve this problem?

Solution

You can run these classes in a test suite Please refer to this question and the answers provided

Or change your design and use the @ beforeclass annotation to run an installation before each test class

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>