Quiz

Which of the statements is correct?

// A) Using JUnit 4.13

@Rule
ExpectedException expectedException = ExpectedException.none();

@Test
public void test_divideByZero() throws DivideByZeroException {
	Calculator calculator = new Calculator();
	expectedException.expect(DivideByZeroException.class);
	calculator.divide(1, 0);
	fail();
}
// B) Using JUnit 5

@Test
public void test_divideByZero(){
	Calculator calculator = new Calculator();
	assertThrows(DivideByZeroException.class, () -> calculator.divide(1, 0));
	fail();
}

Assuming the calculator indeed throws a DivideByZeroException when trying to divide by zero. Which of the following statements is correct:






progress bar illustration

Q1

Q2

Q3

Q4