BAEL-183 - refactoring and moving testng to dedicated module
This commit is contained in:
@@ -11,23 +11,24 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
@RunWith(value = Parameterized.class)
|
||||
public class MyParameterisedUnitTest {
|
||||
public class ParametrizedTests {
|
||||
|
||||
private String name;
|
||||
private int value;
|
||||
private boolean isEven;
|
||||
|
||||
public MyParameterisedUnitTest(String myName) {
|
||||
this.name = myName;
|
||||
public ParametrizedTests(int value, boolean isEven) {
|
||||
this.value = value;
|
||||
this.isEven = isEven;
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
Object[][] data = new Object[][]{{"Peter"}, {"Sam"}, {"Tim"}, {"Lucy"}};
|
||||
Object[][] data = new Object[][]{{1, false}, {2, true}, {4, true}};
|
||||
return Arrays.asList(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenName_whenValidLength_thenTrue() {
|
||||
boolean valid = name.length() > 0;
|
||||
Assert.assertEquals(valid, true);
|
||||
public void givenParametrizedNumber_ifEvenCheckOK_thenCorrect() {
|
||||
Assert.assertEquals(isEven, value % 2 == 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.junit4vstestng;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class RegistrationTest {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RegistrationTest.class);
|
||||
|
||||
@Test
|
||||
public void whenCalledFromSuite_thanOK() {
|
||||
LOGGER.info("Registration successful");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.junit4vstestng;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SignInTest {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SignInTest.class);
|
||||
|
||||
@Test
|
||||
public void whenCalledFromSuite_thanOK() {
|
||||
LOGGER.info("SignIn successful");
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({ StringCaseTest.class, DivisibilityTest.class })
|
||||
@Suite.SuiteClasses({ RegistrationTest.class, SignInTest.class })
|
||||
public class SuiteTest {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user