Created
March 16, 2021 10:07
-
-
Save SiAust/f6c6d53e5138444112a7c4af7be7d839 to your computer and use it in GitHub Desktop.
Simple example of JUnit
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
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import java.util.Arrays; | |
public class JUnitTest { | |
@Test | |
public void CalculatorTest() { | |
Calculator calculator = new Calculator(); | |
assertEquals(10, calculator.sum("1234")); | |
} | |
} | |
class Calculator { | |
public int sum(String digits) { | |
return Arrays.stream(digits.split("")).map(Integer::valueOf) | |
.reduce(Integer::sum).get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment