Created
November 20, 2023 17:08
-
-
Save nadvolod/dafa330947d3ed7b48e7fe0a2cb1f995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.saucelabs.saucebindings.junit4.examples; | |
public class ConditionTester { | |
private boolean actionDone; | |
public boolean option1(boolean conditionA, boolean conditionB) { | |
if (!conditionA) { | |
actionDone = true; // Represents "Another action" | |
return actionDone; | |
} | |
if (conditionB) { | |
actionDone = true; // Represents "Do something" | |
} else { | |
actionDone = true; // Represents "Alternative action" | |
} | |
return actionDone; | |
} | |
public boolean option2(boolean conditionA, boolean conditionB) { | |
if (conditionA) { | |
if (conditionB) { | |
actionDone = true; // Represents "Do something" | |
} else { | |
actionDone = true; // Represents "Alternative action" | |
} | |
} else { | |
actionDone = true; // Represents "Another action" | |
} | |
return actionDone; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConditionTesterTest { | |
private final ConditionTester tester = new ConditionTester(); | |
@Test | |
public void testBothOptionsWithConditionATrueAndConditionBTrue() { | |
assertTrue(tester.option1(true, true)); | |
assertTrue(tester.option2(true, true)); | |
} | |
@Test | |
public void testBothOptionsWithConditionATrueAndConditionBFalse() { | |
assertTrue(tester.option1(true, false)); | |
assertTrue(tester.option2(true, false)); | |
} | |
@Test | |
public void testBothOptionsWithConditionAFalse() { | |
assertTrue(tester.option1(false, true)); | |
assertTrue(tester.option2(false, true)); | |
assertTrue(tester.option1(false, false)); | |
assertTrue(tester.option2(false, false)); | |
} | |
} |
SantjagoCorkez
commented
Nov 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment