新的JUnit 4.8.1 @Category渲染测试套件几乎已经过时了吗? [英] Does new JUnit 4.8.1 @Category render test suites almost obsolete?

查看:186
本文介绍了新的JUnit 4.8.1 @Category渲染测试套件几乎已经过时了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出问题 '如何运行属于某个类别的所有测试?'和答案以下方法对于测试组织会更好吗?

Given question 'How to run all tests belonging to a certain Category?' and the answer would the following approach be better for test organization?


  1. 定义包含所有测试的主测试套件(例如使用 ClasspathSuite

  2. 设计足够的JUnit类别集合(足以表示每个理想的测试集合可通过一个或多个类别识别)

  3. 使用相关类别对每个测试进行限定

  4. 基于主测试套件和类别集定义目标测试套件

  1. define master test suite that contains all tests (e.g. using ClasspathSuite)
  2. design sufficient set of JUnit categories (sufficient means that every desirable collection of tests is identifiable by one or more categories)
  3. qualify each test with relevant category(ies)
  4. define targeted test suites based on master test suite and set of categories

示例:


  • 识别速度类别(慢速,快速),依赖项(模拟,数据库,$ b) $ b整合等),功能(填写应用程序类别),域名(填写适用的类别)等。

  • 要求每个测试都经过相应的合格(标记)使用ClasspathSuite(在类路径中找到的所有测试)创建主测试套件

  • 通过使用类别限定主测试套件来创建目标套件,例如:
  • 创建主测试套件
    模拟测试套件,快速数据库测试套件,域X测试套件的慢速集成等。

  • identify categories for speed (slow, fast), dependencies (mock, database, integration, etc.), function (fill in applicable categories), domain (fill in applicable categories), etc.
  • demand that each test is properly qualified (tagged) with relevant set of categories.
  • create master test suite using ClasspathSuite (all tests found in classpath)
  • create targeted suites by qualifying master test suite with categories, e.g. mock test suite, fast database test suite, slow integration for domain X test suite, etc.

我的问题更多比如征求这种方法与经典测试套件方法的批准率。一个无与伦比的好处是每个新测试都立即被相关套件包含,没有套件维护。一个关注是每个测试的正确分类。

My question is more like soliciting approval rate for such approach vs. classic test suite approach. One unbeatable benefit is that every new test is immediately contained by relevant suites with no suite maintenance. One concern is proper categorization of each test.

推荐答案

你需要权衡的一个权衡考虑是恕我直言,类别是在测试中定义的,而套件是在外部定义的。这意味着,当您使用套件时,您知道将运行哪些测试,但在使用类别时,除非您检查测试或简单运行它们,否则您不知道。同时,当您使用测试套件查看测试时,您不知道它包含在哪个套件中,除非检查您的套件,但使用类别,您可以看到它。

One of the trade-off you have to consider is IMHO that categories are defined within the tests and suites are defined outside. This means, that when you use suites, you know which tests will be run, but when using categories, you do not know unless you inspect tests or simple run them. At the same time, when you look at the test using test suites you do not know in which suite it is contained, unless checking your suites, but using categories, you see it immidiatly.

这篇关于新的JUnit 4.8.1 @Category渲染测试套件几乎已经过时了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆