Hi All,
Class:
@Invariant(value = { "null!=content", "!content.trim().isEmpty()" })
public class Word {
@Requires(value = { "null!=c", "!c.trim().isEmpty()"})
public Word(String c) {
content = c;
}
}
Junit:
public class WordTest {
/**
* This is used to test the PreCondition of constructor whose argument type
* is String. If PreCondition fails then it should throw an error.Test for pre
* condition if we pass null.
*/
@Test(expected = PreconditionError.class)
public void TestConstructorForNullString() {
new Word((String) null);
}
}
I have written above code but I never get PreconditionError.
Can anyone help me?
Thanks,
Dipak