When it comes to test your code, is it a good idea to use its own main for testing? The other option would be to use an external file with this tests.
例如:
Class Foo{
Foo(){/*...*/}
public boolean met1(){/*...*/}
//other metodes...
//Tests
public static void main(String args[]){
Foo f = new Foo();
//Test the correctness of data...
boolean r = f.met1();
//check the result...
}
}
What are the pros and cons of this technic. Maybe there are better approaches for testing code that i did not mention.