ALM/Test Automation

JUnitPerf

Terry Cho 2008. 1. 16. 11:59
==

Decorate with style

Decorators aren't limited to a single decoration. For example, in Java™ I/O, it is possible to decorate a FileInputStream with an InputStreamReader with a BufferedReader (just remember this: BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("infilename"), "UTF8"))).

Decoration can happen on multiple levels, and so it is with JUnitPerf's TimedTests and LoadTests. When these two classes decorate each other, it leads to some compelling test scenarios, such as one where a load is placed on a business case and a time threshold is also applied. Or we could just combine the previous two test scenarios as follows:

  • Place a load on the testCreate() method.
  • Specify that every thread must finish within the time threshold.

Listing 4 shows what happens when I apply the above specifications by decorating a normal Test with a LoadTest, which is decorated by a TimedTest:


Listing 4. A decorated load and timed test
public static Test suite() {
 int users = 10;
 Timer timer = new ConstantTimer(100);
 long maxElapsedTime = 2000; 	 
 return new TimedTest(new LoadTest(
   new WidgetDAOImplTest("testCreate"), users, timer), 
     maxElapsedTime);  		
}

As you see, the testCreate() method is run 10 times (each thread launching 100 milliseconds apart), and each thread must complete within two seconds or the entire test scenario will fail.

출처 : Tong - exospace님의 JAVA통
==
위와 같은 방식으로, 기존 JUnit Test case를 Thread수, Thread당 수행 시간, 허용가능 응답시간으로 나눠서 테스트가 가능함.

대신 리포팅 기능이 약한데.
Japex는 리포팅 기능이 매우 강력한 반면, 허용 가능 응답시간이 없는것이 단점.

그리드형