Question: How do I use this: Exception ex = assertThrows ( RuntimeException . class, ( ) - > Project 2 . squareRoot ( - 4 )
How do I use this:
Exception ex assertThrowsRuntimeExceptionclass, ProjectsquareRoot;
to test that the method throws an exception because negative square roots arent allowed.
Use the assertThrows JUnit assertion that takes the class of the expected exception and a lambda expression to run that should throw.
My test method is:
@Test
public void testNegativeCubeRoot
Test cases for cubeRoot
assertEquals ProjectcubeRoot;
assertEquals ProjectcubeRoot;
assertEquals ProjectcubeRoot;
assertEquals ProjectcubeRoot;
assertEquals ProjectcubeRoot;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
