













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of unit testing in java using junit and emma for code coverage, as well as unit testing in c using check. How to write test cases, organize them into suites, and run the tests using these frameworks. It also introduces splint for static checking in c. Junit is a testing harness for java that enables quick and simple test creation, execution, and evaluation. Test cases can be scattered in the code or organized into separate suites. Emma is a free code coverage tool for java that can be used to instrument code or run tests with the emma runner. Code coverage is an indication of how much of the code is being tested, but having good coverage does not necessarily mean having good tests. Check is a unit testing framework for c that follows the same idea as junit. The document also includes examples of test cases and test suites, as well as instructions for running junit, emma, and check.
Typology: Study notes
1 / 21
This page cannot be seen from the preview
Don't miss anything!














java -cp emma.jar:junit-4.5.jar:. emmarun -sp.
-ix +SimpleProg -r html -cp junit-4.5.jar:.
org.junit.runner.JUnitCore testSimpleProg
Output:
splint hello2.c Splint 3.1.1 --- 07 Dec 2007 hello2.c: (in function main) hello2.c:8:11:Variable c used before definition An rvalue is used that may not be initialized to a value on some execution path. (Use -usedef to inhibit warning) hello2.c:11:16: Possibly null storage tmp passed as non-null param: reflect (tmp) A possibly null pointer is passed as a parameter corresponding to a formal parameter with no /@null@/ annotation. If NULL may be used for this parameter, add a /@null@/ annotation to the function parameter declaration. (Use -nullpass to inhibit warning) hello2.c:10:17: Storage tmp may become null hello2.c:11:16: Passed storage tmp not completely defined (tmp is undefined): reflect (tmp) Storage derivable from a parameter, return value or global is not defined. Use /@out@*/ to denote passed or returned storage which need not be defined. (Use -compdef to inhibit warning) hello2.c:10:41: Storage *tmp allocated ............
hello2.c:15:12: Fresh storage tmp not released before return A memory leak has been detected. Storage allocated locally is not released before the last reference to it is lost. (Use -mustfreefresh to inhibit warning) hello2.c:10:41: Fresh storage tmp created hello2.c:1:6: Function exported but not used outside hello2: reflect A declaration is exported, but not used outside this module. Declaration can use static qualifier. (Use -exportlocal to inhibit warning) hello2.c:4:1: Definition of reflect Finished checking --- 5 code warnings zsh: exit 1 splint hello2.c