Created
May 11, 2017 19:00
-
-
Save in28minutes/05d058949ebe220b9d4df3ed747067e3 to your computer and use it in GitHub Desktop.
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
package com.junit.quick.start; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.fail; | |
import org.junit.After; | |
import org.junit.AfterClass; | |
import org.junit.Before; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
public class StringTest { | |
@BeforeClass | |
public static void beforeClass(){ | |
System.out.println("beforeClass"); | |
} | |
@Test | |
public void testToLearnAssertEquals() { | |
System.out.println("test1"); | |
//actualOutput = Math.min(5,10) | |
//expectedOutput = 5 | |
int actualOutput = Math.min(5, 10); | |
int expectedOutput = 5; | |
assertEquals(expectedOutput, actualOutput); | |
//assertEquals(3,2);//expected 3 but was 2 | |
//assertEquals(2,3);//expected 2 but was 3 | |
//assertEquals(3,3);//success | |
} | |
@Test | |
public void testToCheckStringUppercase() { | |
//actualOutput = Math.min(5,10) | |
//expectedOutput = 5 | |
System.out.println("test2"); | |
String value = "abcdefgh"; | |
String actualOutput = value.toUpperCase(); | |
String expectedOutput = "ABCDEFGH"; | |
assertEquals(expectedOutput, actualOutput); | |
//assertEquals(3,2);//expected 3 but was 2 | |
//assertEquals(2,3);//expected 2 but was 3 | |
//assertEquals(3,3);//success | |
} | |
@Test(expected=NullPointerException.class) | |
public void testToCheckStringUppercaseNullPointer() { | |
System.out.println("test2"); | |
String value = null; | |
String actualOutput = value.toUpperCase(); | |
} | |
@AfterClass | |
public static void afterAnything(){ | |
System.out.println("afterClass"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment