Created
July 24, 2019 11:11
-
-
Save biodunalfet/98041cab9791d9cb902228c7654c02d4 to your computer and use it in GitHub Desktop.
Specification for unit test
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.flutterwave.raveandroid.validators; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.JUnit4; | |
import static org.hamcrest.CoreMatchers.is; | |
import static org.junit.Assert.*; | |
@RunWith(JUnit4.class) | |
public class CvvValidatorTest { | |
CvvValidator SUT; //system under test | |
@Before | |
public void setUp() throws Exception { | |
SUT = new CvvValidator(); | |
} | |
//correct cvv returns true | |
//incorrect cvv returns false | |
//UnitBeingTested_particularCase_ExpectedOutcome | |
@Test | |
public void isCvvValid_CorrectCvvPassed_returnsTrue() { | |
//the three As of testing | |
//Arrange | |
//Act | |
//Assert | |
String cvv = "345"; | |
boolean isValid = SUT.isCvvValid(cvv); | |
assertThat(true, is(isValid)); | |
// assertTrue(isValid); | |
} | |
@Test | |
public void isCvvValid_4digitCvvPassed_returnsTrue() { | |
//the three As of testing | |
//Arrange | |
//Act | |
//Assert | |
String cvv = "3345"; | |
boolean isValid = SUT.isCvvValid(cvv); | |
assertThat(true, is(isValid)); | |
// assertTrue(isValid); | |
} | |
@Test | |
public void isCvvValid_CvvPassedLongerThan4_returnsFalse() { | |
//the three As of testing | |
//Arrange | |
//Act | |
//Assert | |
String cvv = "33457"; | |
boolean isValid = SUT.isCvvValid(cvv); | |
assertThat(false, is(isValid)); | |
// assertTrue(isValid); | |
} | |
@Test | |
public void isCvvValid_CvvPassedLessThan3_returnsFalse() { | |
//the three As of testing | |
//Arrange | |
//Act | |
//Assert | |
String cvv = "33"; | |
boolean isValid = SUT.isCvvValid(cvv); | |
assertThat(false, is(isValid)); | |
// assertTrue(isValid); | |
} | |
@Test | |
public void isCvvValid_CvvPassedIsNotDigits_returnsFalse() { | |
//the three As of testing | |
//Arrange | |
//Act | |
//Assert | |
String cvv = "3a3"; | |
boolean isValid = SUT.isCvvValid(cvv); | |
assertThat(false, is(isValid)); | |
// assertTrue(isValid); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment