I have a Java project on intellij with multiple exercices to do for the semester. Some tests are associated with these exercises. However, I cannot run the tests as the build fail because some methods are not yet implemented in other files.
For example, I have a StackWithTwoQueues.java file that I implemented and associated with that I have StackWithTwoQueuesTest.java file. When I run this file, I get "build failed" because some methods in a file MinMaxHeap.java do not contain return value (which makes sense because I'm not worked on this exercise yet).
Is there a way to run the test and ignoring this "build failed" ?
CodePudding user response:
I think it's important to understand the difference between running a build and running a test.
A test runs on compiled code, your code is compiled when you run a build.
To be able to build, the code must be complete with no fatal errors that prevent the code from compiling.
Having half-written code, in this case a method without a return type, will prevent the code from compiling. So to answer your question, no it's not possible.
To solve this, you could:
Comment out the half-written methods, and anywhere that they are called from, you can use a double
//
to do this, or a block comment using/*commented out*/
across multiple lines.Insert some placeholders into the code. For example if change the method declaration to have
void
as the return type. This means it does not expect anything to be returned.
public static void voidMethod() {
- Just return null, or empty string, or an int from these methods.
Basically, as you don't care about these methods, just keep them out of the way. Hope that helps.