Hi Antoni
I certainly don't think this is a terrible idea. In fact, at the University of Canterbury we often have advanced test cases such as the one you describe.
You are right in thinking to use the extra and global extra fields. Unfortunately the java_method question type that comes with coderunner does not make use of these fields. To use them you will need to customize the question. I have attached a customized version of the question (in moodle xml format) you describe with two different ways of implementing the 'Test case 4' you describe.
The first way uses 'Global extra' to store a method for computing the correct answer.
The second way uses the 'extra' field of the test case to run the test code behind the scenes where the student cannot see it. This way the student is only told if they failed a particular test and cannot see any detail that might give away how to solve the question.
If you think this behavior is something you would want on other questions (which I suspect you might). You could consider making your own custom question prototype that uses the customization in my attached question.
Kind regards,
Matthew