[英]Why my JUnit test cases exhibit different output when run as a Test Suite and individual Junit file
I have a set of JUnit test files and also a test suite (Suite class) file which holds the reference to all individual Junit test files. 我有一组JUnit测试文件以及一个测试套件(Suite类)文件,该文件包含对所有单个Junit测试文件的引用。
All are database oriented. 都是面向数据库的。 The database used is Mysql and I am using Eclipse IDE to run the tests. 使用的数据库是Mysql,我使用Eclipse IDE来运行测试。
When running each file individually I get the correct value and the assertion is correct but when running from the test suite it shows a different value. 当单独运行每个文件时,我得到正确的值并且断言是正确的但是当从测试套件运行时它显示不同的值。
I have made each JUnit test file to access the database independently with a different database name (even though the table structure is same) 我已经使每个JUnit测试文件独立地使用不同的数据库名称访问数据库(即使表结构相同)
Whether we need to prevent the JUnit test cases from running parallel / the database related statements need to be verified ? 我们是否需要防止JUnit测试用例并行运行/数据库相关语句需要验证?
I would suggest you look into : 我建议你研究一下:
There are 2 reasons that this may happen. 这可能有两个原因。
One is that you have not constructed the suite properly and some tests share resources with others. 一个是你没有正确构建套件,有些测试与其他测试共享资源。
And the other is that when you finish a test, you don't rollback the database and so the next test finds database in an erroneous state. 另一个是当你完成测试时,你不回滚数据库,所以下一个测试发现数据库处于错误状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.