public class Primes { public static boolean isAPrime(int number) { return number == 2 || number % 2 != 0; } }
- public class Primes {
- public static boolean isAPrime(int number) {
return true;- return number == 2 || number % 2 != 0;
- }
- }
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class SolutionTest { @Test public void twoShouldBeAPrime() { int numberToCheck = 2; boolean expected = true; boolean actual = Primes.isAPrime(numberToCheck); assertEquals(expected, actual); } @Test public void fourShouldNotBeAPrime() { int numberToCheck = 4; boolean expected = false; boolean actual = Primes.isAPrime(numberToCheck); assertEquals(expected, actual); } }
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- public class SolutionTest {
- @Test
- public void twoShouldBeAPrime() {
- int numberToCheck = 2;
- boolean expected = true;
- boolean actual = Primes.isAPrime(numberToCheck);
- assertEquals(expected, actual);
- }
- @Test
- public void fourShouldNotBeAPrime() {
- int numberToCheck = 4;
- boolean expected = false;
- boolean actual = Primes.isAPrime(numberToCheck);
- assertEquals(expected, actual);
- }
- }