Skip to content

Instantly share code, notes, and snippets.

@alpersilistre
Last active May 13, 2018 21:33
Show Gist options
  • Save alpersilistre/4560f22541c51402fddc0df059afe8ec to your computer and use it in GitHub Desktop.
Save alpersilistre/4560f22541c51402fddc0df059afe8ec to your computer and use it in GitHub Desktop.
public class MultiplicationTests {
@Test
public void MultiplicationOfZeroIntegerShouldReturnZero() {
assertEquals(0, Main.Multiplication(10, 0));
assertEquals(0, Main.Multiplication(0, 10));
assertEquals(0, Main.Multiplication(0, 0));
}
@Test
public void MultiplicationOfOneIntegerShouldReturnItself() {
int a = 25;
int b = 35;
assertEquals(a, Main.Multiplication(a, 1));
assertEquals(b, Main.Multiplication(1, b));
}
@Test(expected = IllegalArgumentException.class)
public void MultiplicationOfElementShouldReturnExceptionIfItsMoreThanThousand() {
Main.Multiplication(1000, 6);
}
}
public class SumTest {
@Test
public void test() {
int output = Main.Sum(5, 10);
assertEquals(15, output);
}
}
public class Main {
public static void main(String[] args) {
System.out.println("Welcome to the JUnit 4");
}
public static int Square(int x) {
return x * x;
}
public static int Sum(int x, int y) {
return x + y;
}
public static int Multiplication(int x, int y) {
// if(x > 999) {
// throw new IllegalArgumentException("X should be less than 1000");
// }
return x * y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment