I start using Junit, and I have a very basic question.
I want to check the method rateTrans. I don’t implement this yet, but I want to write the test before the implemention. I know which arguments this method would get.
So I wrote the next class:
import org.junit.Assert.*;
import junit.framework.*;
public class testing extends TestCase {
public void testAdd(){
assertTrue(rateTrans("1223",1,2,3,4,"blabla"));
assertTrue(rateTrans("1223",1,2,3,4,"")) ;
assertFalse(rateTrans("1223",7,2,3,4,"blabla"));
}
}
It gives me the next problem: The method rateTrans(String, int, int, int, int, String) is undefined for the type testing.
What I do wrong?
Just implement it with an empty body and/or
nullas return value (well, in this casefalsemight be a good choice):Congratulations, you’re doing TDD! Once you’ve implemented all the tests you may implement the method itself. Until then some tests might be green, due to the boolean return value, while others are red.