在 JUnit 5 测试中,我如何测试一个数字是正数还是负数或两者的混合?

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

我是 JUnit 测试的新手。我试过使用条件,但使用 assertEquals 似乎不起作用。例如, assertEquals(1 > 0, 10) 给我一个失败的测试。还有另一种方法吗?谢谢。

使用 assertTrue,在你的情况下:assertTrue(x > 0).

您可以找到所有提供的 assertion-types here.