[size=12]Hello,
I m new to JUnit and i donot know how to write test cases to test code.
I m also finding it difficut to test the DB operations.
Is the server on which the project is usually run , supposed to be started when i want to run the Junit test cases?
And cant we write DB operations testing in Junit? instead of dbunit?
Please help!!
Code which is not running is as follows:
public class SimpleJdbcUserDAOTest {
SimpleJdbcUserDAO usrdao;
static final String name="@ron";
final User user=new User(name,"abcxyz","What?","Yes","1");
@Test
public void testInsert() {
int i=usrdao.insert(user);
assertEquals("Should not accept special characters!", i, 0);
}
Pooja Gadre wrote:Is the server on which the project is usually run , supposed to be started when i want to run the Junit test cases?
Only if you are trying to test on the server, say with a remote call. It is valid to test without the server to test the database code. We do this here on JForum.
Pooja Gadre wrote:And cant we write DB operations testing in Junit? instead of dbunit?
Of course. DBUnit sits on top of JUnit to make database loads easier.
Right now i m giving sample data to test units. but when i run the test case using the option "run as junit test case" in Springsource Tool Suite (STS), i am not getting the expected result. my application is connected to the database and a web server. So is it necessary to keep running the server in the background to make the test case show a green signal?
Pooja Gadre wrote:, i am not getting the expected result.
We are going to need more information about why it isn't working to give you a helpful reply. Are you getting a database error? Is it pointing to the wrong database? Are you getting some other exception? See TellTheDetails for more tips on giving helpful information to people who can give advice.