简体   繁体   English

Junit 3,Junit 4,TestNG和有什么不一样

[英]what is the difference between Junit 3, Junit 4, TestNG

what is the difference between JUnit 3, JUnit 4, TestNG in selenium how selenium is implemented differently in these three testing frameworks? 硒中的JUnit 3,JUnit 4,TestNG有什么区别?在这三个测试框架中硒的实现方式有何不同?

Can any one explain clearly.. 任何人都可以清楚地解释一下..

Thanks in Advance.. 提前致谢..

  1. TestNG handles dependency between test cases. TestNG处理测试用例之间的依赖关系。 If one test case failure causes the failure of a group of test cases it skips that group and executes the rest of the test suite. 如果一个测试用例失败导致一组测试用例失败,它将跳过该组并执行其余测试套件。 The group that has dependency on the failed test cases is reported as skipped NOT failed. 依赖失败的测试用例的组被报告为跳过未失败。

    In Junit, one test case failure can cause a bunch of test cases to fail in the test suite. 在Junit中,一个测试用例失败会导致测试套件中的许多测试用例失败。 There is no option of skipping the set of dependent test cases. 没有选择跳过依赖测试用例集的选项。 The dependent test cases are also reported as failures. 从属测试用例也报告为失败。 For example, suppose there is a test case to test login and the next 10 test cases need to perform a transaction after login. 例如,假设有一个测试用例来测试登录,接下来的10个测试用例需要在登录后执行事务。 If the login test case fails the other 10 test cases will also fail. 如果登录测试用例失败,则其他10个测试用例也将失败。

  2. In TestNG groups can be defined. 在TestNG中,可以定义组。 Groups are specific subsets of the test suite. 组是测试套件的特定子集。 We can choose to run only a specific subset of the test suite say database related test cases instead of running the entire test suite. 我们可以选择只运行测试套件的特定子集(例如与数据库相关的测试用例),而不运行整个测试套件。 This can be done as below: 可以按照以下步骤完成:

    In the test case we define two groups DBTestcase and deprecated as below: 在测试用例中,我们定义了两个组DBTestcase,并且已弃用,如下所示:

     @Test(groups = {"DBTestcase", "deprecated"}) public void testMethod2() { } 

    In Junit for a long time it was not possible to run a specific subset of the test cases. 在Junit中很长时间无法运行测试用例的特定子集。 We can either run the entire suite or run each test case individually. 我们既可以运行整个套件,也可以单独运行每个测试用例。 Junit 4.8 introduced a new feature called “Categories” to overcome this limitation. Junit 4.8引入了一个名为“类别”的新功能来克服此限制。 However groups are much easier to configure in TestNG. 但是,在TestNG中配置组要容易得多。

    Thus if you have junit 3.x series you cannot define groups. 因此,如果您具有junit 3.x系列,则无法定义组。 However junit 4.8 and above supports it. 但是junit 4.8及更高版本支持它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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