BAEL-183 - refactoring and moving testng to dedicated module

This commit is contained in:
slavisa-baeldung
2017-02-18 22:56:41 +01:00
parent aef624dd8b
commit 333953b204
17 changed files with 172 additions and 126 deletions

View File

@@ -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);
}
}

View File

@@ -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");
}
}

View File

@@ -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");
}
}

View File

@@ -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 {
}