1.1)to create a timed test that waits for the completion of the ExampleTestCase.testOneSecondResponse() method and then fails if the elapsed time exceeded 1 second
Code example:
long maxElapsedTime = 1000;
Test testCase = new ExampleTestCase("testOneSecondResponse");
Test timedTest = new TimedTest(testCase, maxElapsedTime);
1.2)产生一个Non-Waiting Timed Tests
to create a timed test that fails immediately when the elapsed time of the ExampleTestCase.testOneSecondResponse() test method exceeds 1 second
Code example:
long maxElapsedTime = 1000;
Test testCase = new ExampleTestCase("testOneSecondResponse");
Test timedTest = new TimedTest(testCase, maxElapsedTime, false);
本文介绍如何使用JUnit创建定时测试案例,包括等待型与非等待型定时测试。通过设定最大允许耗时来确保测试方法能在预期时间内完成,超过时限则视为失败。
23万+

被折叠的 条评论
为什么被折叠?



