-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing Parameterized tests in JUnit4
- Loading branch information
1 parent
1237fab
commit 342cd21
Showing
4 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=1.7 | ||
org.eclipse.jdt.core.compiler.source=1.8 |
17 changes: 17 additions & 0 deletions
17
junit-4-basics/src/main/java/com/giriharan/StringUtils.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.giriharan; | ||
|
||
import java.util.stream.IntStream; | ||
|
||
public class StringUtils { | ||
|
||
String addString(String s1,String s2) | ||
{ | ||
return s1+s2; | ||
} | ||
|
||
int countVowels(String s) | ||
{ | ||
return (int) s.chars().filter(arg -> arg=='a' || arg=='e' || arg=='i' || arg=='o' || arg=='u').count(); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
junit-4-basics/src/test/java/com/giriharan/StringUtilsParamTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.giriharan; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
@RunWith(Parameterized.class) | ||
public class StringUtilsParamTest { | ||
|
||
StringUtils su; | ||
String s1,s2,expected; | ||
|
||
@Before | ||
public void init() | ||
{ | ||
su = new StringUtils(); | ||
} | ||
|
||
public StringUtilsParamTest(String s1,String s2,String res) | ||
{ | ||
this.s1 = s1; | ||
this.s2 = s2; | ||
this.expected = res; | ||
} | ||
|
||
|
||
@Parameters | ||
public static Object[] testAddValues() { | ||
return new Object[] { | ||
new Object[] {"Hello","World","HelloWorld"}, | ||
new Object[] {"","world" ,"world"}, | ||
new Object[] {"hello","","hello"} | ||
}; | ||
} | ||
|
||
@Test | ||
public void testAdd() { | ||
assertEquals(expected,su.addString(s1, s2)); | ||
} | ||
|
||
} |