java - how to unit test code that should cause compile error -




i have class take arraylist parameter:

public class foo {     private arraylist<bar> bars;      public foo(arraylist barlist) {         bars = barlist;     } } 

there bug can pass arraylist constructor:

// should compile error line foo foo = new foo(new arraylist<string>()); 

the problem if add case test suite, when bug fixed, can not compile it. there anyway test case?

i don't know of language/unit test framework let "test" code should not compile. if can't compile it, there nothing test. can turn on compiler warnings when building. i'm pretty sure passing unparameterized collection big warning in jvm after jdk5.





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -