harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Hu <roberthu...@gmail.com>
Subject [classlib][test] "fail" statements omitted in many exception catching test cases
Date Wed, 27 Sep 2006 07:02:20 GMT
Hi All,

In our unit test of classlib, there are huge number of test cases about exception catching.
The typical style of those cases is like that:

	try {
		someStatementShouldThrowAnException;
*	      fail("Expected an exception");*
	} catch (SomeException e){
		// Expected
	}

If we omit the "fail" statement, the test case is wrong because the exception-throwing checking
is disabled.

I've found that the "fail" statement is omitted in many test cases of our Harmony classlib.
So I set some rules to find out all lines of code related with it. If a line of code comform
all the 5 rules, it may be a bug:
1.in a "*Test.java" file
2.does not start with "//"
3.contains "catch"
4.its previous line does not contains "fail"
5.its next line contains "//" or "}"


Then I found out 1711 lines of code in 309 files comform all the 5 rules in r450321. (Attachment
file is the result.)
Of course not all of them are bug, because some test cases are not of above style.

And I also find out some real bugs, we can fix them easilly:
trunk\modules\awt\src\test\api\java\common\java\awt\font\TextLayoutTest.java:652\658\664\670\676\685\698\704\711(line
number)
trunk\modules\luni\src\test\java\org\apache\harmony\tests\java\lang\EnumTest.java:57
trunk\modules\luni\src\test\java\org\apache\harmony\luni\tests\java\io\FileInputStreamTest.java:36
trunk\modules\luni\src\test\java\org\apache\harmony\luni\tests\java\io\FileOutputStreamTest.java:35
<more>......

*I must say frankly that it's hard to find out all bugs of this kind without any "victims"
automatically, we must find out real bugs ourselves.*

Hope the result in attachment file can help us to find out more bugs.

Anybody has better search rules or better solution to find out those bugs? Pls. share with
us, thanks a lot.

-- 
Robert Hu
China Software Development Lab, IBM


Mime
View raw message