PreCondtions are never execusted

92 views
Skip to first unread message

Dipak Jadhav

unread,
Mar 17, 2016, 4:07:44 PM3/17/16
to cofoja
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
Reply all
Reply to author
Forward
0 new messages