Wednesday, 15 January 2014

Java Unit Testing with a memory consumption contraint -



Java Unit Testing with a memory consumption contraint -

i want able write unit test, in suite of performance tests distinct fast functional tests simulates issue , fails, right issue such test passes. illustration when execution time constraint 20 milliseconds, test must fail if takes more 20ms otherwise passes. , if want set memory consumption constraint , if consumption more constraint, test must fail. possible can write test memory consumption constraint?

for timing constraint can utilize @org.junit.rules.timeout (although it's not rule meant for) or write own variation thereof. memory constraint can write org.junit.rules.testrule compares memory usage before , after test. 2 ways measure memory usage java.lang.runtime class , jmx.

as performance depends on many factors (load of ci server, how much code has been jitted, etc.), remains seen if results conclusive/stable enough. may thought run tests many times , compare averages.

testing memory junit constraints consumption

No comments:

Post a Comment