I execute tests, while I observed ”has a @Test annotation but also a return value: ignoring it. Use to fix this” and execution terminated. [My Env - Java + Maven + TestNG ]

Any idea how to resolve this issue?


All test methods should be void. It's in the test assertions that confirms if your code is producing the intended output. Example :

public void testAddBanana() {
//Your data setup and invocation of the add method
assertTrue(ans == result);

For more information of the different types of annotations and assertions, check the documentation.

  • Good one. Accepted Adrian – NarendraC Jul 29 '16 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.