BAEL-183 Updated after review
This commit is contained in:
		
							parent
							
								
									1bf70b8f08
								
							
						
					
					
						commit
						23696a24bd
					
				| @ -6,41 +6,41 @@ import org.testng.annotations.Test; | |||||||
| 
 | 
 | ||||||
| public class DependentTests { | public class DependentTests { | ||||||
| 
 | 
 | ||||||
| 	private EmailValidator emailValidator; |     private EmailValidator emailValidator; | ||||||
| 	private LoginValidator loginValidator; |     private LoginValidator loginValidator; | ||||||
| 	private String validEmail = "abc@qwe.com"; |     private String validEmail = "abc@qwe.com"; | ||||||
| 
 | 
 | ||||||
| 	@BeforeClass |     @BeforeClass | ||||||
| 	public void setup(){ |     public void setup() { | ||||||
| 		emailValidator = new EmailValidator(); |         emailValidator = new EmailValidator(); | ||||||
| 		loginValidator = new LoginValidator(); |         loginValidator = new LoginValidator(); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@Test |     @Test | ||||||
| 	public void validEmailTest() { |     public void givenEmail_ifValid_thenTrue() { | ||||||
| 	    boolean valid = emailValidator.validate(validEmail); |         boolean valid = emailValidator.validate(validEmail); | ||||||
| 	    Assert.assertEquals(valid, true); |         Assert.assertEquals(valid, true); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@Test(dependsOnMethods={"validEmailTest"}) |     @Test(dependsOnMethods = { "givenEmail_ifValid_thenTrue" }) | ||||||
| 	public void validateLogin() { |     public void givenValidEmail_whenLoggedin_thenTrue() { | ||||||
| 	    boolean valid = loginValidator.validate(); |         boolean valid = loginValidator.validate(); | ||||||
| 	    Assert.assertEquals(valid, true); |         Assert.assertEquals(valid, true); | ||||||
| 	} |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class EmailValidator{ | class EmailValidator { | ||||||
| 
 | 
 | ||||||
| 	public boolean validate(String validEmail) { |     public boolean validate(String validEmail) { | ||||||
| 		return true; |         return true; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class LoginValidator{ | class LoginValidator { | ||||||
| 
 | 
 | ||||||
| 	public boolean validate() { |     public boolean validate() { | ||||||
| 		return true; |         return true; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,21 @@ | |||||||
|  | package com.baeldung.test.comparison; | ||||||
|  | 
 | ||||||
|  | import static org.junit.Assert.assertEquals; | ||||||
|  | 
 | ||||||
|  | import org.junit.BeforeClass; | ||||||
|  | import org.junit.Test; | ||||||
|  | 
 | ||||||
|  | public class DivisibilityTest { | ||||||
|  | 
 | ||||||
|  |     private static int number; | ||||||
|  | 
 | ||||||
|  |     @BeforeClass | ||||||
|  |     public static void setup() { | ||||||
|  |         number = 40; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void givenNumber_whenDivisiblebyTwo_thenCorrect() { | ||||||
|  |         assertEquals(number % 2, 0); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -27,24 +27,23 @@ public class MyParameterisedUnitTest { | |||||||
| 
 | 
 | ||||||
|     @Parameters |     @Parameters | ||||||
|     public static Collection<Object[]> data() { |     public static Collection<Object[]> data() { | ||||||
|         Object[][] data  |         Object[][] data = new Object[][] { { "Peter" }, { "Sam" }, { "Tim" }, { "Lucy" } }; | ||||||
|           = new Object[][] { { "Peter" }, { "Sam" }, { "Tim" }, { "Lucy" } }; |  | ||||||
|         return Arrays.asList(data); |         return Arrays.asList(data); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     public void pushNameTest() { |     public void givenName_whenValidLength_thenTrue() { | ||||||
|         boolean valid = nameCheck.nameCheck(name); |         boolean valid = nameCheck.nameCheck(name); | ||||||
|         Assert.assertEquals(valid, true); |         Assert.assertEquals(valid, true); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class NameCheck{ | class NameCheck { | ||||||
| 
 | 
 | ||||||
| 	public boolean nameCheck(String name) { |     public boolean nameCheck(String name) { | ||||||
| 		if(name.length()>0) |         if (name.length() > 0) | ||||||
| 			return true; |             return true; | ||||||
| 		return false; |         return false; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,73 +8,74 @@ import org.testng.annotations.Test; | |||||||
| 
 | 
 | ||||||
| public class MyParameterisedUnitTestNg { | public class MyParameterisedUnitTestNg { | ||||||
| 
 | 
 | ||||||
| 	private PrimeNumberCheck primeNumberChecker; |     private PrimeNumberCheck primeNumberChecker; | ||||||
| 
 | 
 | ||||||
| 	@BeforeClass |     @BeforeClass | ||||||
| 	public void intialSetup(){ |     public void intialSetup() { | ||||||
| 	    primeNumberChecker = new PrimeNumberCheck(); |         primeNumberChecker = new PrimeNumberCheck(); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@Test(enabled=false) |     @Test(enabled = false) | ||||||
| 	@Parameters({"num","expectedResult"}) |     @Parameters({ "num", "expectedResult" }) | ||||||
| 	public void parameterCheckTest(int number,boolean expectedResult) { |     public void givenNumber_ifPrime_thenCorrect(int number, boolean expectedResult) { | ||||||
| 	    Assert.assertEquals(expectedResult, |         Assert.assertEquals(expectedResult, primeNumberChecker.validate(number)); | ||||||
| 	    primeNumberChecker.validate(number)); |     } | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	@DataProvider(name = "test1") |     @DataProvider(name = "test1") | ||||||
| 	public static Object[][] primeNumbers() { |     public static Object[][] primeNumbers() { | ||||||
| 	    return new Object[][] { |         return new Object[][] { { 2, true }, { 6, false }, { 19, true }, { 22, false }, { 23, true } }; | ||||||
| 	      {2, true}, {6, false}, {19, true}, {22, false}, {23, true}}; |     } | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	@Test(dataProvider = "test1") |     @Test(dataProvider = "test1") | ||||||
| 	public void testPrimeNumberChecker(Integer inputNumber, Boolean expectedResult) { |     public void givenNumber_whenPrime_thenCorrect(Integer inputNumber, Boolean expectedResult) { | ||||||
| 	    Assert.assertEquals(expectedResult, |         Assert.assertEquals(expectedResult, primeNumberChecker.validate(inputNumber)); | ||||||
| 	    primeNumberChecker.validate(inputNumber)); |     } | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	@Test(dataProvider = "myDataProvider") |     @Test(dataProvider = "myDataProvider") | ||||||
| 	public void parameterCheckTest(User user) { |     public void parameterCheckTest(User user) { | ||||||
| 	    Assert.assertEquals("sam",user.getName()); |         Assert.assertEquals("sam", user.getName()); | ||||||
| 	    Assert.assertEquals(12,user.getAge()); |         Assert.assertEquals(12, user.getAge()); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@DataProvider(name = "myDataProvider") |     @DataProvider(name = "myDataProvider") | ||||||
| 	public Object[][] parameterProvider() { |     public Object[][] parameterProvider() { | ||||||
| 	    User usr = new User(); |         User usr = new User(); | ||||||
| 	    usr.setName("sam"); |         usr.setName("sam"); | ||||||
| 	    usr.setAge(12); |         usr.setAge(12); | ||||||
| 	    return new Object[][]{{usr}}; |         return new Object[][] { { usr } }; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class PrimeNumberCheck{ | class PrimeNumberCheck { | ||||||
| 
 | 
 | ||||||
| 	public Object validate(int number) { |     public Object validate(int number) { | ||||||
| 		for(int i=2;i<number;i++) { |         for (int i = 2; i < number; i++) { | ||||||
| 	        if(number%i==0) |             if (number % i == 0) | ||||||
| 	            return false; |                 return false; | ||||||
| 	    } |         } | ||||||
| 	    return true; |         return true; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class User{ | class User { | ||||||
| 	private String name; |     private String name; | ||||||
| 	private int age; |     private int age; | ||||||
| 	public String getName() { | 
 | ||||||
| 		return name; |     public String getName() { | ||||||
| 	} |         return name; | ||||||
| 	public void setName(String name) { |     } | ||||||
| 		this.name = name; | 
 | ||||||
| 	} |     public void setName(String name) { | ||||||
| 	public int getAge() { |         this.name = name; | ||||||
| 		return age; |     } | ||||||
| 	} | 
 | ||||||
| 	public void setAge(int age) { |     public int getAge() { | ||||||
| 		this.age = age; |         return age; | ||||||
| 	} |     } | ||||||
|  | 
 | ||||||
|  |     public void setAge(int age) { | ||||||
|  |         this.age = age; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,12 +0,0 @@ | |||||||
| package com.baeldung.test.comparison; |  | ||||||
| 
 |  | ||||||
| import org.junit.Test; |  | ||||||
| 
 |  | ||||||
| public class MyTest1 { |  | ||||||
| 
 |  | ||||||
| 	@Test |  | ||||||
| 	public void suiteTest1() { |  | ||||||
| 
 |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,10 +0,0 @@ | |||||||
| package com.baeldung.test.comparison; |  | ||||||
| 
 |  | ||||||
| import org.junit.Test; |  | ||||||
| 
 |  | ||||||
| public class MyTest2 { |  | ||||||
| 	@Test |  | ||||||
| 	public void suiteTest2() { |  | ||||||
| 
 |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -4,8 +4,8 @@ import org.testng.annotations.Test; | |||||||
| 
 | 
 | ||||||
| public class RegistrationTest { | public class RegistrationTest { | ||||||
| 
 | 
 | ||||||
| 	@Test |     @Test | ||||||
| 	public void givenEmail_ifValid_thenCorrect(){ |     public void givenEmail_ifValid_thenCorrect() { | ||||||
| 
 | 
 | ||||||
| 	} |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -4,9 +4,9 @@ import org.testng.annotations.Test; | |||||||
| 
 | 
 | ||||||
| public class SignInTest { | public class SignInTest { | ||||||
| 
 | 
 | ||||||
| 	@Test |     @Test | ||||||
| 	public void givenUsername_ifValid_thenCorrect(){ |     public void givenUsername_ifValid_thenCorrect() { | ||||||
| 
 | 
 | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,22 @@ | |||||||
|  | package com.baeldung.test.comparison; | ||||||
|  | 
 | ||||||
|  | import static org.junit.Assert.assertEquals; | ||||||
|  | 
 | ||||||
|  | import org.junit.BeforeClass; | ||||||
|  | import org.junit.Test; | ||||||
|  | 
 | ||||||
|  | public class StringCaseTest { | ||||||
|  | 
 | ||||||
|  |     private static String data; | ||||||
|  | 
 | ||||||
|  |     @BeforeClass | ||||||
|  |     public static void setup() { | ||||||
|  |         data = "HELLO BAELDUNG"; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void givenString_whenAllCaps_thenCorrect() { | ||||||
|  |         assertEquals(data.toUpperCase(), data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -4,10 +4,7 @@ import org.junit.runner.RunWith; | |||||||
| import org.junit.runners.Suite; | import org.junit.runners.Suite; | ||||||
| 
 | 
 | ||||||
| @RunWith(Suite.class) | @RunWith(Suite.class) | ||||||
| @Suite.SuiteClasses({ | @Suite.SuiteClasses({ StringCaseTest.class, DivisibilityTest.class }) | ||||||
|   MyTest1.class, | public class SuiteTest { | ||||||
|   MyTest2.class |  | ||||||
| }) |  | ||||||
| public class MyTest5 { |  | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @ -1,5 +1,6 @@ | |||||||
| package com.baeldung.test.comparison; | package com.baeldung.test.comparison; | ||||||
| 
 | 
 | ||||||
|  | import java.security.Security; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| 
 | 
 | ||||||
| @ -12,7 +13,7 @@ import org.junit.Ignore; | |||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| 
 | 
 | ||||||
| public class SummationServiceTest { | public class SummationServiceTest { | ||||||
| 	private static List<Integer> numbers; |     private static List<Integer> numbers; | ||||||
| 
 | 
 | ||||||
|     @BeforeClass |     @BeforeClass | ||||||
|     public static void initialize() { |     public static void initialize() { | ||||||
| @ -38,23 +39,21 @@ public class SummationServiceTest { | |||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     public void givenNumbers_sumEquals_thenCorrect() { |     public void givenNumbers_sumEquals_thenCorrect() { | ||||||
|         int sum = 0; |         int sum = numbers.stream() | ||||||
|         for (int num : numbers) |             .reduce(0, Integer::sum); | ||||||
|             sum += num; |  | ||||||
|         Assert.assertEquals(6, sum); |         Assert.assertEquals(6, sum); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Ignore |     @Ignore | ||||||
|     @Test |     @Test | ||||||
| 	public void givenEmptyList_sumEqualsZero_thenCorrect(){ |     public void givenEmptyList_sumEqualsZero_thenCorrect() { | ||||||
| 		 int sum = 0; |         int sum = numbers.stream() | ||||||
| 	        for (int num : numbers) |             .reduce(0, Integer::sum); | ||||||
| 	            sum += num; |         Assert.assertEquals(6, sum); | ||||||
| 	        Assert.assertEquals(6, sum); |     } | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
|     @Test(expected = ArithmeticException.class) |     @Test(expected = ArithmeticException.class) | ||||||
|     public void calculateWithException() {  |     public void givenNumber_whenThrowsException_thenCorrect() { | ||||||
|         int i = 1/0; |         int i = 1 / 0; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -13,89 +13,82 @@ import org.testng.annotations.BeforeGroups; | |||||||
| import org.testng.annotations.BeforeMethod; | import org.testng.annotations.BeforeMethod; | ||||||
| import org.testng.annotations.Test; | import org.testng.annotations.Test; | ||||||
| 
 | 
 | ||||||
| public class SummationServiceTestTestNg extends TestNG{ | public class SummationServiceTestTestNg extends TestNG { | ||||||
| 
 | 
 | ||||||
| 	private List<Integer> numbers; |     private List<Integer> numbers; | ||||||
| 
 | 
 | ||||||
| 	private int testCount=0; |     private int testCount = 0; | ||||||
| 
 | 
 | ||||||
| 	@BeforeClass |     @BeforeClass | ||||||
| 	public void initialize() { |     public void initialize() { | ||||||
| 		numbers = new ArrayList<>(); |         numbers = new ArrayList<>(); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@AfterClass |     @AfterClass | ||||||
| 	public void tearDown() { |     public void tearDown() { | ||||||
| 		numbers = null; |         numbers = null; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@BeforeMethod |     @BeforeMethod | ||||||
| 	public void runBeforeEachTest() { |     public void runBeforeEachTest() { | ||||||
| 	   testCount++; |         testCount++; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@AfterMethod |     @AfterMethod | ||||||
| 	public void runAfterEachTest() { |     public void runAfterEachTest() { | ||||||
| 
 | 
 | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@BeforeGroups("negative_tests") |     @BeforeGroups("negative_tests") | ||||||
| 	public void runBeforeEachNegativeGroup() { |     public void runBeforeEachNegativeGroup() { | ||||||
| 	    numbers.clear(); |         numbers.clear(); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@BeforeGroups("regression") |     @BeforeGroups("regression") | ||||||
| 	public void runBeforeEachRegressionGroup() { |     public void runBeforeEachRegressionGroup() { | ||||||
| 	    numbers.add(-11); |         numbers.add(-11); | ||||||
| 	    numbers.add(2); |         numbers.add(2); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@BeforeGroups("positive_tests") |     @BeforeGroups("positive_tests") | ||||||
| 	public void runBeforeEachPositiveGroup() { |     public void runBeforeEachPositiveGroup() { | ||||||
| 	    numbers.add(1); |         numbers.add(1); | ||||||
| 	    numbers.add(2); |         numbers.add(2); | ||||||
| 	    numbers.add(3); |         numbers.add(3); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@AfterGroups("positive_tests,regression,negative_tests") |     @AfterGroups("positive_tests,regression,negative_tests") | ||||||
| 	public void runAfterEachGroup() { |     public void runAfterEachGroup() { | ||||||
| 	    numbers.clear();  |         numbers.clear(); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@Test(groups="positive_tests",enabled=false) |     @Test(groups = "positive_tests", enabled = false) | ||||||
|     public void givenNumbers_sumEquals_thenCorrect() { |     public void givenNumbers_sumEquals_thenCorrect() { | ||||||
|         int sum = 0; |         int sum = numbers.stream().reduce(0, Integer::sum); | ||||||
|         for (int num : numbers) |  | ||||||
|             sum += num; |  | ||||||
|         Assert.assertEquals(sum, 6); |         Assert.assertEquals(sum, 6); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 	@Test(groups="negative_tests") |     @Test(groups = "negative_tests") | ||||||
| 	public void givenEmptyList_sumEqualsZero_thenCorrect(){ |     public void givenEmptyList_sumEqualsZero_thenCorrect() { | ||||||
| 		 int sum = 0; |         int sum = numbers.stream().reduce(0, Integer::sum); | ||||||
| 	        for (int num : numbers) |         Assert.assertEquals(0, sum); | ||||||
| 	            sum += num; |     } | ||||||
| 	        Assert.assertEquals(0, sum); |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	@Test(groups = "regression") |     @Test(groups = "regression") | ||||||
| 	public void givenNegativeNumber_sumLessthanZero_thenCorrect() { |     public void givenNegativeNumber_sumLessthanZero_thenCorrect() { | ||||||
| 	    int sum = 0; |         int sum = numbers.stream().reduce(0, Integer::sum); | ||||||
| 	    for (int num : numbers) |         Assert.assertTrue(sum < 0); | ||||||
| 	        sum += num; |         ; | ||||||
| 	    System.out.println(sum); |     } | ||||||
| 	    Assert.assertTrue(sum<0);; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	@Test(groups="sanity") |     @Test(groups = "sanity") | ||||||
| 	public void givenNumbers_doSum(){ |     public void givenNumbers_doSum() { | ||||||
| 
 | 
 | ||||||
| 	} |     } | ||||||
| 	 |  | ||||||
| 	@Test(expectedExceptions = ArithmeticException.class)  |  | ||||||
| 	public void calculateWithException() {  |  | ||||||
| 	    int i = 1/0; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
|  |     @Test(expectedExceptions = ArithmeticException.class) | ||||||
|  |     public void givenNumber_whenThrowsException_thenCorrect() { | ||||||
|  |         int i = 1 / 0; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,8 +3,9 @@ package com.baeldung.test.comparison; | |||||||
| import org.testng.annotations.Test; | import org.testng.annotations.Test; | ||||||
| 
 | 
 | ||||||
| public class TimeOutTest { | public class TimeOutTest { | ||||||
| 	@Test(timeOut = 1000,enabled=false) |     @Test(timeOut = 1000, enabled = false) | ||||||
| 	public void testInfinity() { |     public void givenExecution_takeMoreTime_thenFail() { | ||||||
| 	    while (true); |         while (true) | ||||||
| 	} |             ; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										49
									
								
								core-java/src/test/java/temp/SummationServiceTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								core-java/src/test/java/temp/SummationServiceTest.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,49 @@ | |||||||
|  | package temp; | ||||||
|  | 
 | ||||||
|  | import static org.junit.Assert.*; | ||||||
|  | 
 | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import org.junit.After; | ||||||
|  | import org.junit.AfterClass; | ||||||
|  | import org.junit.Before; | ||||||
|  | import org.junit.BeforeClass; | ||||||
|  | import org.junit.Test; | ||||||
|  | 
 | ||||||
|  | import junit.framework.Assert; | ||||||
|  | 
 | ||||||
|  | public class SummationServiceTest { | ||||||
|  | 
 | ||||||
|  |     private static List<Integer> numbers; | ||||||
|  | 
 | ||||||
|  |     @BeforeClass | ||||||
|  |     public static void initialize() { | ||||||
|  |         numbers = new ArrayList<>(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @AfterClass | ||||||
|  |     public static void tearDown() { | ||||||
|  |         numbers = null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Before | ||||||
|  |     public void runBeforeEachTest() { | ||||||
|  |         numbers.add(1); | ||||||
|  |         numbers.add(2); | ||||||
|  |         numbers.add(3); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @After | ||||||
|  |     public void runAfterEachTest() { | ||||||
|  |         numbers.clear(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void givenNumbers_sumEquals_thenCorrect() { | ||||||
|  |         int sum = 0; | ||||||
|  |         for (int num : numbers) | ||||||
|  |             sum += num; | ||||||
|  |         assertEquals(6, sum); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user