CFP last date
20 December 2024
Reseach Article

Unit Testing Concurrent Java Programs

by Suma Shivaprasad, Nanditha Prasad
International Journal of Computer Applications
Foundation of Computer Science (FCS), NY, USA
Volume 67 - Number 10
Year of Publication: 2013
Authors: Suma Shivaprasad, Nanditha Prasad
10.5120/11435-6798

Suma Shivaprasad, Nanditha Prasad . Unit Testing Concurrent Java Programs. International Journal of Computer Applications. 67, 10 ( April 2013), 41-46. DOI=10.5120/11435-6798

@article{ 10.5120/11435-6798,
author = { Suma Shivaprasad, Nanditha Prasad },
title = { Unit Testing Concurrent Java Programs },
journal = { International Journal of Computer Applications },
issue_date = { April 2013 },
volume = { 67 },
number = { 10 },
month = { April },
year = { 2013 },
issn = { 0975-8887 },
pages = { 41-46 },
numpages = {9},
url = { https://ijcaonline.org/archives/volume67/number10/11435-6798/ },
doi = { 10.5120/11435-6798 },
publisher = {Foundation of Computer Science (FCS), NY, USA},
address = {New York, USA}
}
%0 Journal Article
%1 2024-02-06T21:24:20.466574+05:30
%A Suma Shivaprasad
%A Nanditha Prasad
%T Unit Testing Concurrent Java Programs
%J International Journal of Computer Applications
%@ 0975-8887
%V 67
%N 10
%P 41-46
%D 2013
%I Foundation of Computer Science (FCS), NY, USA
Abstract

Conventional unit-testing practices focus on testing small units of programs sequentially and are very likely to miss concurrent bugs such as race conditions, deadlocks and memory inconsistencies even when done extensively. They are not suitable for unit testing multithreaded programs. This paper outlines guidelines for writing effective unit tests for concurrent Java programs. It also explores and compares the frameworks available currently for writing such tests. The most widely used unit testing frameworks for Java - TestNG and JUnit - do not provide good support for testing concurrent issues. Other frameworks such as MultiThreadedTC and Concurrency Analyzer allow the coordination of unit test's threads to produce a speci?c scheduling. However, it is the responsibility of the developer to test for all possible interleavings and scheduling of threads to unearth existing bugs and hence they are a deterministic way of approaching the problem. This paper presents an alternate approach to the problem by integrating TestNG with the Java Path Finder(JPF) software model checker. JPF can be used to identify all possible interleavings of threads across execution paths to non deterministically detect concurrent bugs. In addition to this, it detects deadlocks by checking if all the threads have reached a blocked state at any point of execution. Adoption of such practices have helped in reducing concurrency related issues in our platforms to a great extent. It has helped in identifying issues early on in the development cycle and better reliability. Many open source platforms such as Ehcache run concurrent unit tests as part of their development process to maintain code quality. This, augmented with stress testing concurrency tools greatly help in improving the quality of code.

References
  1. W. Pugh and N. Ayewah. Unit testing concurrent software. In ASE')7: Proceedings of the twenty-second IEEEE/ACM International Conference on automated software engineering, ACM, pages 513-516, NY,USA, 2007.
  2. B. Long, D. Hoffman, P. Strooper. Tool Support for testing concurrent Java components, IEEE Transactions on Software Engineering,29(6):555-566, 2003.
  3. Brain Goetz, Joshua Bloch, Tim Peierls, Java Concurrency in Practice, Addison Wesley, July 2009.
  4. Doug Lea. Concurrent Programming in Java, Second Edition. Addison –Wesley 2000.
  5. MultithreadedTC. http:/code. google/p//multithreadedTc. com
  6. B. Long. Testing Concurrent Java Components. PhD thesis, The University of Queensland, July 2005.
  7. Orit Edelstein, Eitan Farchi, Evgeny Goldin, Yarden Nir, Gil Ratsaby, Shmuel Ur: Framework for testing multi-threaded Java programs. Concurrency and Computation: Practice and Experience 15(3-5): 485-499, 2003 .
  8. Orit Edelstein, Eitan Farchi, Yarden Nir, Gil Ratsaby, and Shmuel Ur Multithreaded java program test generation. IBM Systems Journal, 41(1):111–125, 2002.
  9. C. Beust and A. Popescu. Testng: Testing, the next generation. http://www. testng. org, 2007.
  10. TestNG unit testing framework http://testng. org The JPF Testing Framework http://JPF. sourceforge. net
Index Terms

Computer Science
Information Sciences

Keywords

Concurrent Programming TestNG Java Path Finder JUnit Model checking Thread scheduling Deadlocks Concurrent Unit Testing ConAN MultithreadedTC ConTest