Comrade Stalin
Comrade Stalin

Reputation: 35

In JUnit 5 test, how can I test a number whether it is positve or negative or a mix of both?

I'm new to JUnit testing. I've tried using conditions, but it doesn't seem to work using assertEquals. For example, assertEquals(1 > 0, 10) which gives me a failed test. Is there another way of doing it? Thanks.

Upvotes: 1

Views: 1800

Answers (1)

Moritz Groß
Moritz Groß

Reputation: 1490

Use assertTrue, in your case: assertTrue(x > 0).

You can find all provided assertion-types here.

Upvotes: 4

Related Questions