Commit 4deb3327 authored by Shanelle Valencia's avatar Shanelle Valencia

Add more tests

parent e4882a87
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -32,4 +32,20 @@ public class CalculatorTest { ...@@ -32,4 +32,20 @@ public class CalculatorTest {
Assert.assertEquals(res, 30); Assert.assertEquals(res, 30);
} }
@Test
public void assertNotNull() {
Calculator calc = new Calculator();
Assert.assertNotNull(calc);
}
@Test public void assertNull() {
Calculator calc = new Calculator();
Assert.assertNull("Failed: Not Null", calc);
}
} }
...@@ -11,6 +11,8 @@ import java.util.List; ...@@ -11,6 +11,8 @@ import java.util.List;
public class StringsTest { public class StringsTest {
String string;
@Before @Before
public void beforeTest() { public void beforeTest() {
...@@ -46,13 +48,39 @@ public class StringsTest { ...@@ -46,13 +48,39 @@ public class StringsTest {
@Test @Test
public void testEvenWordsInSent() { public void testEvenWordsInSent() {
List<String> evens = new Strings().evenWordsInSent("This is a sentence with even and odd words"); String sentence = "This is a sentence with even and odd words";
List<String> actual = Arrays.asList("This", "is", "sentence", "with", "even"); List<String> expected = new Strings().evenWordsInSent(sentence);
List<String> actual = Arrays.asList(sentence.split(" "));
// List<String> actual = Arrays.asList("This", "is", "sentence", "with", "even");
// Assert.assertEquals("Failed", expected, actual);
Assert.assertNotEquals(expected, actual);
}
@Test
public void assertNotEquals() {
String sentence = "This is a sentence with even and odd words";
List<String> expected = new Strings().evenWordsInSent(sentence);
List<String> actual = Arrays.asList(sentence.split(" "));
Assert.assertEquals(evens, actual); Assert.assertNotEquals(expected, actual);
} }
@Test
public void assertNotSame() {
String sentence = "This is a sentence with even and odd words";
List<String> expected = new Strings().evenWordsInSent(sentence);
List<String> actual = Arrays.asList(sentence.split(" "));
Assert.assertNotSame("Failed: expected and actual are the same", expected, actual);
}
@AfterClass @AfterClass
//must be static bc its a class method //must be static bc its a class method
public static void afterClass() { public static void afterClass() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment