Reputation: 3
@Requires("d >= 0") //pre-condition
@Ensures("data == d") //post-condition
public Natural(int d) {
data = d;
}
how can i test "data == d" on JUnit without using assert?
Upvotes: 0
Views: 330
Reputation: 15714
You should not rely on assert
statements for your tests, as this can be disabled.
You should instead look through the Assert
class in JUnit, which has a number of methods for testing results.
In your case, I presume you have either access to data
, or can determine a side effect of data
, which can be tested.
Upvotes: 2