user9044901
user9044901

Reputation: 3

Junit test on this method without using assert?

@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

Answers (1)

Joe C
Joe C

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

Related Questions