Search Based Software Testing Using JUnit

I was talking about JUnit the other day. I heard a few voices from the audience asking about a significant benefit of JUnit. It appeared that for them JUnit was quite ordinary. JUnit allows to unit test software. If you have written a class, you can check whether its methods work really well according to the specifications using JUnit. You can test that class and its methods in isolation. Whether or not the rest of your work is even developed does not matter. Once you have a class ready, you can test it using JUnit. This alone is a huge benefit of JUnit.

You, nonetheless, have to provide the test cases, against which you want to check the methods, by yourself. For small methods, requiring only a handful of input arguments, and only a handful of possible values for those arguments, JUnit alone can suffice as a unit test framework. You can provide those values by reading the software specification. However, when the number of possible values to be input is very large, running the tests manually can be limiting. Even if you are using a smart way of providing the inputs, through looping, by employing a brute force testing scheme, there could be limits to what you can achieve with JUnit. You may not be able to test all the possible combinations of values which your method can accept. Moreover, the method under test might as well have failed on a certain combination that you failed to provide. Brute force algorithms work well when the combination of values is rather small. As you increase that number, brute force schemes begin to reveal their appetite for computing resources. Moreover, if the software is very sensitive to a certain range of inputs, it becomes all the more important to check its functioning against those values.

Search techniques based on meta-heuristics come in handy to rescue such situations. With search techniques, you can automate your tests. Search techniques are also well-known for exploring the regions of search space that are hard to reach manually or through other algorithms.

Meta-heuristic search algorithms, such as genetic algorithms have been widely applied to the feat of software testing in the past. The idea of coupling them with JUnit is also not very exceptional. Here I am listing a few links that reflect on this type of work. You never know you might like these ideas. And you may as well end up working on some of these for your future career.

A Complete Automation of Unit Testing for Java Programs

Program testing is expensive and labor-intensive, often consuming more than half of the total development costs, and yet it is frequently not done well and the results are not always satisfactory. However, testing is the primary method to ensure that programs comply with requirements.

Evolutionary testing of classes | ACM SIGSOFT Software Engineering Notes

Object oriented programming promotes reuse of classes in multiple contexts. Thus, a class is designed and implemented with several usage scenarios in mind, some of which possibly open and generic. Correspondingly, the unit testing of classes cannot make …

No Title

A Static Approach to Prioritizing JUnit Test Cases | IEEE Journals & Magazine | IEEE Xplore

No Title

Strategy for mutation testing using genetic algorithms | IEEE Conference Publication | IEEE Xplore

Improving Structural Testing of Object-Oriented Programs via Integrating Evolutionary Testing and Symbolic Execution | Proceedings of the 23rd IEEE/ACM International Conference on Automated Software Engineering

Achieving high structural coverage such as branch coverage in object-oriented programs is an important and yet challenging goal due to two main challenges. First, some branches involve complex program logics and generating tests to cover them requires deep knowledge of the program structure and semantics.

Evolutionary testing of autonomous software agents | Proceedings of The 8th International Conference on Autonomous Agents and Multiagent Systems – Volume 1

A system built in terms of autonomous agents may require even greater correctness assurance than one which is merely reacting to the immediate control of its users. Agents make substantial decisions for themselves, so thorough testing is an important consideration.

Photo by snowpeak

If you found an error, highlight it and press Shift + Enter or click here to inform us.

CC BY-NC-ND 4.0 Search Based Software Testing Using JUnit by Psyops Prime is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Leave a Reply