0

How do you test a method which doesn’t return any values in JUnit/TestNG??

Can you control Junit/TestNG Results from tests?

These are questions I've come across during my interview? How do I answer them??

user3195193
  • 45
  • 1
  • 2
  • 8

2 Answers2

0

Maybe by testing that no Exception is thrown and that the produced side-effect is as expected. It depends on your context though. As for your question:

Can you control Junit/TestNG Results from tests?

Maybe using method fail().

xav
  • 5,452
  • 7
  • 48
  • 57
0

You can control method fail - for example exception throwing. For example assert that the code should throw an exception. You have and array and want to check that your array. JUnit example:

@Test(expected = SomeException.class)
public void testMethod() {
    testMethod(int someValue); // You accept that it should throw an exception
}
Ashot Karakhanyan
  • 2,804
  • 3
  • 23
  • 28