- Get link
- X
- Other Apps
What should we do to check whether your codes have bug?
TESTING!
But, how to determine how well your testing is?
That's why we need to check the code coverage.
In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite.
-- Wikipedia
Assume that we have the following function:
//m / n
public int devide (int m, int n) throw Exception {
if (n == 0) {
throws new Exception();
}
return m /= n;
}
if we test something like this:
devide (11, 12);
devide (0, 1);
devide (3, 2);
these test cases do not cover all the cases in the method,
it misses out 1 case: which is n == 0.
Using a code coverage tool will help you find out which line you have missed,
and ensure your tests quality.
However, how many percent of code coverage should we aim for?
Look at this blog to learn more!
~~~~~~
Recommend a java Eclipse tool EclEmma,
Detail tutorial can be found here:
http://quarbby.wordpress.com/2014/04/17/eclipse-eclemma-java-code-coverage/
Thanks to Lynnette! (Since she has written 1, so I won't write a new 1 xD)
A good youtube tutorial for EclEmma.
~~~~~~
That's all for today. Thank you!
**Reference: CS2103T module website
pharaoh
17/4/2014
6:07p.m.
TESTING!
But, how to determine how well your testing is?
That's why we need to check the code coverage.
In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite.
-- Wikipedia
Assume that we have the following function:
//m / n
public int devide (int m, int n) throw Exception {
if (n == 0) {
throws new Exception();
}
return m /= n;
}
if we test something like this:
devide (11, 12);
devide (0, 1);
devide (3, 2);
these test cases do not cover all the cases in the method,
it misses out 1 case: which is n == 0.
Using a code coverage tool will help you find out which line you have missed,
and ensure your tests quality.
However, how many percent of code coverage should we aim for?
Look at this blog to learn more!
~~~~~~
Recommend a java Eclipse tool EclEmma,
Detail tutorial can be found here:
http://quarbby.wordpress.com/2014/04/17/eclipse-eclemma-java-code-coverage/
Thanks to Lynnette! (Since she has written 1, so I won't write a new 1 xD)
A good youtube tutorial for EclEmma.
~~~~~~
That's all for today. Thank you!
**Reference: CS2103T module website
pharaoh
17/4/2014
6:07p.m.
- Get link
- X
- Other Apps
Comments
Post a Comment