Results 1 to 3 of 3
  1. #1
    dellacpa is offline Member
    Join Date
    Aug 2010
    Posts
    16
    Rep Power
    0

    Default JUnit test - AssertEquals

    Hi,
    I am trying to create a test for a method in my program. The methods, when working right, should give me the values 1 or 2 (BOTH ARE RIGHT).

    How can test it with assertEquals? In other words, how can I tell JUnit to report the test as passed if the value the method returns is 1 or 2.

    The problem is that I do not know a priori if it is 1 or 2, but everything else (3, 4....) would be wrong.

    Any help?

    Thanks, Patrick

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    Mhm, maybe
    Java Code:
    		int returnValue = bar();
    		assertTrue(returnValue == 1 || returnValue == 2);
    :confused:

  3. #3
    dellacpa is offline Member
    Join Date
    Aug 2010
    Posts
    16
    Rep Power
    0

Similar Threads

  1. junit test problem
    By moamen in forum Eclipse
    Replies: 2
    Last Post: 03-14-2010, 09:41 PM
  2. JUNIT testing assertEquals function
    By Drun in forum New To Java
    Replies: 7
    Last Post: 01-22-2010, 06:08 PM
  3. Replies: 1
    Last Post: 08-03-2009, 05:31 PM
  4. JUnit Test Help!
    By pharo in forum New To Java
    Replies: 0
    Last Post: 04-10-2009, 05:15 PM
  5. Junit test
    By alice in forum New To Java
    Replies: 1
    Last Post: 06-14-2008, 01:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •