Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all: Is there a reason you have to retrieve the subject under test (SUT) from the Spring Application context? For efficient unit testing you should be able to create the SUT without the context. It sounds like you have some hidden dependencies somewhere. That might be the root of some of your headache.</p> <blockquote> <p>How are DAO classes tested esp when a single insertion or updation might leave the database in a "unstable" state [in cases where let's say 3 insertions into different tables actually form a single transaction]?</p> </blockquote> <p>It seems you are worried about the database's constistency after you have running the tests. If possible use a own database for testing, where you don't need care about it. If you have such a sandbox database you can delete data as you wish. In this case I would do the following:</p> <ol> <li>Flag all your fake data with some common identifier, like putting a special prefix to a field.</li> <li>Before running the test drop a delete statement, which deletes the flagged data. If there is none, then nothing bad happens.</li> <li>Run your single DAO test. After that repeat step 2. for the next test.</li> </ol> <blockquote> <p>What is the de-facto standard for functional testing web services which move around a lot of data i.e. mindless insertions/retrievals from the data store?</p> </blockquote> <p>I am not aware of any. From the question your are asking I can infer that you have on one side the web service and on the other side the database. Split up the responsibilities. Have separate test suites for each side. One side just testing database access (as described above). On the other side just testing web service requests and responses. In this case it pays of the stub/fake/mock the layer talking to the network. Or consider <a href="https://wsunit.dev.java.net/" rel="nofollow noreferrer">https://wsunit.dev.java.net/</a>.</p> <p>If the program is only shoving data in and out I think that there is not much behavior. If this is the case, then the hardest work is to unit test the database side and the web service side. The point is you can do unit testing without the need for "realistic" data. For functional testing you will need handrolled data, which is close to reality. This might be cumbersome, but if you already unit tested the database and web service parts intensively, this should reduce the need for "realistic" test cases considerably.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload