Last active
February 28, 2020 17:31
-
-
Save sauceaaron/4701bd4c39e0e7fb280fa57d55ba8610 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import org.testng.annotations.DataProvider; | |
| import org.testng.annotations.Test; | |
| import static org.assertj.core.api.Assertions.assertThat; | |
| public class AdditionWithDataProvider | |
| { | |
| @Test(dataProvider = "additionParameters") | |
| public void testAddition(int a, int b, int sum) | |
| { | |
| assertThat(a + b).isEqualTo(sum); | |
| } | |
| @DataProvider(name = "additionParameters") | |
| public Object[][] getAdditionParameters() { | |
| return new Object[][] { | |
| { 1, 1, 2 }, | |
| { 2, 2, 4 }, | |
| { 5, -14, -9} | |
| }; | |
| } | |
| } |
This file contains hidden or 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
| import org.testng.annotations.Test; | |
| import static org.assertj.core.api.Assertions.assertThat; | |
| public class AdditionWithoutDataProvider | |
| { | |
| @Test | |
| public void testOnePlusOne() | |
| { | |
| assertThat(1 + 1).isEqualTo(2); | |
| } | |
| @Test | |
| public void testTwoPlusTwo() | |
| { | |
| assertThat(2 + 2).isEqualTo(5); | |
| } | |
| @Test | |
| public void testFivePlusNegativeFourteen() | |
| { | |
| assertThat(5 + -14).isEqualTo(-9); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment