[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 725
  • Last Modified:

JUnit, assert multiple values

I have two posibilies for a defined int  to be true. How can i use something like this

int actual = getActualInt();


Assert.assertEquals(actual, 1); or  Assert.assertEquals(actual, 2);

0
mertez
Asked:
mertez
  • 2
1 Solution
 
ksivananthCommented:
Assert.assertTrue( ( actual == 1 || actual == 2 ) );
0
 
mertezAuthor Commented:
is there any difference between assertTrue and assertEquals?

thank you
0
 
ksivananthCommented:
assertTrue - just check the value is true/false
assertEquals - compares two values for equalness
0
 
Gurvinder Pal SinghCommented:
assertTrue tells if the conditions are true

assertEquals tells if the parameters passed to the method are equal or not
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now