Fastpoint
级别: 总版主
精华:
44
发帖: 5033
基地声望: 390 点
基地币: 1683 Bug
基地贡献: 0 点
好评度: 15 点
在线时间:818(小时)
注册时间:2005-10-08
最后登录:2008-07-22
|
[FAQ]JUnit 测试包(Test Suite)构造
引用Kent Beck, Erich Gamma,连接地址:http://junit.sourceforge.net/doc/cookbook/cookbook.htm
How do you run several tests at once?
As soon as you have two tests, you'll want to run them together. You could run the tests one at a time yourself, but you would quickly grow tired of that. Instead, JUnit provides an object, TestSuite which runs any number of test cases together.
For example, to run a single test case, you execute:
TestResult result= (new MoneyTest("testMoneyMoneyBag")).run(); To create a suite of two test cases and run them together, execute: TestSuite suite= new TestSuite(); suite.addTest(new MoneyTest("testMoneyEquals")); suite.addTest(new MoneyTest("testSimpleAdd")); TestResult result= suite.run(); Another way is to let JUnit extract a suite from a TestCase. To do so you pass the class of your TestCase to the TestSuite constructor. TestSuite suite= new TestSuite(MoneyTest.class); TestResult result= suite.run();
Use the manual way when you want a suite to only contain a subset of the test cases. Otherwise the automatic suite extraction is the preferred way. It avoids you having to update the suite creation code when you add a new test case.
TestSuites don't only have to contain TestCases. They contain any object that implements the Test interface. For example, you can create a TestSuite in your code and I can create one in mine, and we can run them together by creating a TestSuite that contains both:
TestSuite suite= new TestSuite(); suite.addTest(Kent.suite()); suite.addTest(Erich.suite()); TestResult result= suite.run();
[ 此贴被Fastpoint在2005-10-17 11:03重新编辑 ]
|
可不可不要这么样徘徊在目光内 你会察觉到我根本寂寞难耐 即使千多百个深夜曾在梦境内 我有吻过你这毕竟并没存在
人声车声开始消和逝 无声挣扎有个情感奴隶 是我多么的想她 但我偏偏只得无尽叹谓
其实每次见你我也着迷 无奈你我各有角色范围 就算在寂寞梦内超出好友关系 唯在暗里爱你暗里着迷 无谓要你惹上各种问题 共我道别吧别让空虚使我越轨
|
|
[楼 主]
|
Posted: 2005-10-14 19:30 |
| |