p-unit

p-unit is an open source framework for performance benchmark and unit test
Download

p-unit Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Publisher Name:
  • Andrew Zhang
  • Operating Systems:
  • Windows All / Unix
  • File Size:
  • 2.6 MB

p-unit Tags


p-unit Description

p-unit is an open source framework for performance benchmark and unit test, which supports to run the same tests solo or concurrently, generates the result in the form of plain text, image or pdf file and tracks memory and time consumption. Test Suite and Test Class Test suite and test class are two important concepts in p-unit. p-unit does not require any special type for a test class, so every class can be a test class. Of course, it includes junit test cases. There is one special interface for special p-unit only test class - p-unitTest. p-unit executes a normal test as following procedure: · invoke setUp if there is. · invoke the test method. · invoke tearDown method. Noticed that setUp and tearDown will also be regarded as a part of performance test. If you don't want to count them into performance data, you need to implement p-unitTest interface, which will be executed as: · invoke setUpBeforeWatchers. · invoke setAfterWatchers. · invoke the test method. · invoke tearDownBeforeWatchers. · invoke tearDownAfterWatchers. As the name suggests, you can put the setUp and tearDown code into the setUpBeforeWatchers and tearDownAfterWatchers. Time/Memory Record p-unit records the memory and time consumption of running a test method. There is a "watcher" concept in p-unit, which supervises the status during running the test method. By default, memory watcher and time watcher are installed. p-unit supports user-defined watcher too. The user only needs to implement the Watcher interface and register it to p-unit method runner. By default, time watcher is enabled. If you want to watch memory consumption, you need to add one line code: runner.methodRunner().addWatcher(new MemoryWatcher()); Concurrent p-unit supports to run the test concurrently. How to write it? You DON'T need to write anything about concurrent in your test - just the same as a normal test. You only need to use p-unitConcurrentRunner to run your test concurrently. For more detail, please refer to Runner. Runner Runner is the core concept of p-unit. You need a runner to run your test. By default, there are two different runners - solo runner and concurrent runner, so that one test can be executed solo and concurrently. Is it complex to launch a runner? ONE line code: new SoloRunner().run(MyTest.class); or new ConcurrentRunner().run(MyTest.class); By default, p-unitConcurrentRunner starts up 10 threads to execute the test method. You can configure it in the constructor of p-unitConcurrentRunner(int threadCount), and you can even do fine control in your test class. If you need to execute different test class with different thread count, you only need to implement Concurrent interface for your test, which requires to return concurrentCount.


p-unit Related Software