I'm doing some unit tests with Junit and I have a doubt to do an exercise.
When the test class is created, test cases are created for each method. Now, if you want to try only one method ... is it convenient to eliminate the rest of the tests that have been created for each method ?, or should they stay as they are all?
Also, if I have a class instantiated in the main class with its initialized attributes with exact values (for example: amount of money in an account among others), when performing the test of a "withdrawMoney" method, the Test class is supposed to have that attribute initialized in the main class to recalculate the balance, no? Or should I start a variable in the method test so that the test can be executed?
Hello, I have another question, I continue with the unit tests and I do not understand what I have wrong in the following code:
@Test
public double testIngresar() throws Exception {
System.out.println("ingresar");
CCuenta instance = new CCuenta();
double resultado = instance.ingresar(100.5);
assertEquals(2600.5, resultado);
System.out.print(resultado);
}
The error that comes out of "incompatible types, void can not be converted to double" in the line where I declare the result variable I do not understand because I get it. The enter () method is declared in the CClase class as double too, I have a small mess of concepts as you can see ...