Skip to content

Instantly share code, notes, and snippets.

@sauceaaron
Last active February 28, 2020 17:31
Show Gist options
  • Save sauceaaron/4701bd4c39e0e7fb280fa57d55ba8610 to your computer and use it in GitHub Desktop.
Save sauceaaron/4701bd4c39e0e7fb280fa57d55ba8610 to your computer and use it in GitHub Desktop.
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}
};
}
}
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