Need Help Writing Testcases

Bryce McKinlay mckinlay@redhat.com
Thu May 6 19:18:00 GMT 2004


Ranjit Mathew wrote:

>Hi,
>
>    I was trying to add testcases for PR9685 and PR15073
>to the libjava testsuite when I realised that I had
>ventured into unknown territory. Can someone help
>me please?
>
>1. Where do I add these tests (checking for illegal
>   package-private accesses)? libjava.compile or libjava.lang?
>  
>

If its just a compile test (ie test for successful compilation, or test 
that compilation fails correctly), then it should go in libjava.compile. 
If its a runtime test, ie you want the testuite to run the code and 
check the output, then it should go in libjava.lang.

>2. One file in each testcase needs to be in a different package,
>   so at least after compilation, the class files should be
>   in another folder. Can I achieve this without adding another
>   folder to CVS? How do I tell the testsuite machinery that
>   (say) PR9685.java and "foo/PR9685_1.java" should be linked
>   together?
>
>   I see some testcases in libjava.compile that are in a
>   non-default package and some that use classes in a sub-folder
>   but I don't fully understand how they manage it.
>

The one test that is in subdirectory doesn't actually work - is doesn't 
get compiled. However, for libjava.compile if you put a main() class in 
the top-level directory that refers to source files in a sub-package, 
then that is sufficient to test source compilation . This is what the 
tests that use the "support" package do. I don't think there is a way to 
actually link & run a test case spread across multiple packages, however.

Bryce



More information about the Java mailing list