Reputation: 1
Hi i want to create DAO unit test in SPRING mvc for example for this type of code
package users;
public interface UserDAO {
public void setDataSource(DataSource ds);
public void create(int id, int personal, String password, String first_name, String last_name, String role,
String email, Date date, int id_team);
public User getUser(Integer user_id);
public List<User> listUsers();
void create1(int id, int personal, String password, String first_name, String last_name, String role, String email,
Date start_date);
}
...what is the best way to do it
Upvotes: 0
Views: 108
Reputation: 8057
For simpler DAO methods, which don't use proprietary sql functions you can use in memory relational database, like HSQLDB.
You configure it as a datasource for your tests. You can start and populate it during test set up and the data will not be persisted anywhere after the test is done.
Seeing the methods you want to test, I suggest you take a look at Spring Data. All these methods are already implemented for you, all you have to do is configure and set up the interface
Upvotes: 1