Listing 1 illustrates that a TestSuite is composed of class instances of Test classes.
清单1表明TestSuite是由test类的类实例组成的。
Figure 13: Class library to generate the test suite tables from the UML definition
图13:类库用来从UML定义产生测试套件表
Test the Web service by adding scaffolding to the controller class.
通过向控制器类中添加scaffolding来测试Web服务。
Now that I have my test class defined I can start developing (and testing) the application.
定义了测试类后,就可以开始开发(并测试)这个应用程序了。
Finally, the two lines at the bottom allow you to run the tests within this test class by simply running this module.
最后的两行负责在这个测试类内部运行测试,方法是直接运行该模块即可。
The above listing is a test class which performs basic tests on the feedparser module.
上述清单是实现feedparser模块基本测试功能的测试类。
When nose looks inside of a test class, it runs methods matching that same regular expression.
当nose 检查测试类的内部时,它运行与同一正则表达式匹配的方法。
JsfTestCase: This is the base test class for unit tests for Servlet and JSF components in a web application.
AbstractJsfTestCase:这是对web应用的Servlet和JSF组件进行单元测试的基础测试类。
The runner is smart enough to figure out which test class depends on which version of JUnit and invoke it appropriately.
运行程序足够智能,可以分辨出哪个测试类依赖于哪个版本的JUnit,并适当地调用它。
With JSFUnit API, the test class methods can submit data on a form and verify that managed beans are properly updated.
有了JSFUnitAPI,测试类方法可以提交表单数据,并且验证管理的bean是否被正确更新。
Eclipse's JUnit integration can generate the test class automatically, so I can minimize my work by letting the tools do it for me.
集成在Eclipse上的JUnit可以自动生成测试类,因此我让工具为我生成,从而减小我的工作量。
If the test class doesn't run, spend your time getting XPath support working before spending hours on writing code that might not work when it counts.
如果测试类不能运行,那么请在编写代码之前花点时间获得XPath支持,否则编写的代码可能不会正常运行。
Rather than building the history stack directly into the photo gallery, we generated a simple page to test our class.
我们没有直接在相册应用程序中建立历史堆栈,而是用一个简单的页面测试这个类。
Now, let's run the test case class on IE, Firefox and Safari browser.
现在,我们将在IE、Firefox和Safari浏览器上运行测试用例类。
Within the UML model, create a test package and class, and include a few attributes or operations.
在uml模型中,创建测试包和类,并且包含一些属性或操作。
JUnit provides a TestRunner class to execute test cases.
JUnit提供了一个TestRunner类来执行测试用例。
AfterTestMethod methods are executed after the execution of every test method in a class.
afterTestMethod方法在类中的每个测试方法执行之后执行。
BeforeTestMethod methods are executed before the execution of any test method in a class.
beforeTestMethod方法在类中的任何测试方法执行之前执行。
You can test your factorial class using the following code, which you'll also find in the file factorial.py (see Resources).
可以用下面的代码测试这个Factorial类,可以在文件factorial . py中找到这些代码(请参阅参考资料)。
As you can see, the unit test for a domain class now (with Grails 1.1) extends GrailsUnitTestCase.
可以看到,现在对一个域类的单元测试(在Grails 1.1中)扩展了GrailsUnitTestCase。
It might take marginally longer to test every class, but this way you can begin filling gaps and fixing bugs almost immediately, rather than waiting a few days for a Jester run to complete.
可能需要更长时间来测试每个类,但是用这种方法,几乎可以立即填补不足、修复bug,而不必为Jester的一次运行完成等上好几天。
Doing so provides a design for the class that the test will exercise, allowing you to focus on small chunks of code.
这样就为要测试的类提供了一种设计,这种设计使您每一时刻都只需集中考虑一小块代码。
What I mean is that you simply pretend that the class you are writing the test for exists.
我的意思是,您只需假定您正在为其编写测试的类已经存在。
You estimate a day to write each database access class and unit test it, so 150 tables at one table per day is 150 days.
估计您每天能编写一个数据库访问类并完成其单元测试,因此,150 个表要用 150天的时间。
The listing shows a utility class that gets used by the unit test.
这个清单给出单元测试使用的实用程序类。
The test case for the Bike class in Listing 3 demonstrates the use of the automatically generated accessor.
清单3中Bike类的测试用例展示了如何使用自动生成的访问器。
Summary: If you have not already done so, delegate some or all of your advice logic to another class that you can test directly.
概述:如果还没有做的话,可以将一些或者全部建议逻辑委派给其他可以直接测试的类。
For example, they can help you test your custom Exception class, verify that your datatype's Equals & GetHashCode are consistent, and check IList invariants.
例如,它可以帮你测试自定义的异常类,验证自定义类型的Equals和GetHashCode方法是否一致,以及检查IList的不变性。
With the above code in place, let's move on to examining how you can run your test of the ServiceClass class successfully in different scenarios.
以上代码就绪后,让我们继续检验怎样在各种场景中成功地运行ServiceClass类的测试。
Unit tests are written from the developer's perspective and focus on particular methods of the class under test. Use these guidelines when writing unit tests
单元测试是从开发人员的角度出发编写的,并且关注的是所测试的类的特定方法。
应用推荐