Wednesday, November 9, 2011

Convert existing junit 4 testcases into perf tests in 2 minutes


Have junitperf jar in your compile and runtime classpath

add following code in a main method in ur junit class
public static void main(..) { int users = 4; int iterations = 5; JUnit4TestAdapter testCase = new JUnit4TestAdapter(MyOwnJunit.class); junit.framework.Test loadTest = new LoadTest(testCase, users, iterations);; }


run junit as java program instead of junit
similar decorators can be used for performance testing just as for multi-threaded testing. This can be huge time saver to quickly test any code for concurrent access issues, that get reported. You can make these concurrent access unit tests as part of your CI as well.

No comments: