开发者

Java: How to do testing for DAO and Services for a module?

First, I'm working as a Java programmer, and my first taks is to test the DAO and Services layers for a module from a 开发者_开发问答project, but I didn't receive so many details about this thing.

Any info for doing this? I know i need to use mock testing.

P.S. This is my first job and I have 2 weeks as a worker :D, so I know very little about testing.


Take a look at this link, I only glossed over it, but it looks like it covers much of the basics. There are many ways to test and there is no good way to answer this question without more detail. In general, it is good to test the DAO layer without actually going to the database... this article should get you started. You might also search google with keywords like java mock test or java test ioc -- IOC is inversion of control which is useful for this sort of thing b/c it allows the container to decide what implementation to use, which allow you to do things like replace database calls with simple value returns. Take a look at this link for more info on IOC. Hope that helps.


Does the component you are going to test contain JUnit test classes? If not, read up on JUnit and start creating a few test classes to get aqainted with JUnit, otherwise have a look at what they do, maybe debug through a few of them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜