views:

38

answers:

1

Me and a co-worker are having a debate. We are on a craptastic legacy project and are slowly adding acceptance tests. He believes that we should be doing the work in the gui/watin then using a low level library to query the database directly for to get an 'end to end' test as he puts it.

We are using NHibernate and I advocate using gui/watin then those nhibernate objects to do the assertions in the acceptance testing. He dislikes the dependency of NHibernate in the test. My assertion was that we have/should have integration tests against the NHibernate objects to make sure they are working with DB the way we intend at which point there is no downside in using them in the acceptance test to assert proper operation. I also think his low level sql dependence will make the tests fragile and duplicate business logic in alot of cases.

Integration testing in our shop basically means its a single component with a dependency e.g. fileRepository/FileSystem Domain-NhibernateObject/Database. Acceptance testing means coming in through the GUI. Unit means all dependencies have/can be mocked/stubbed out and you've got a pure test in memory with only the method under test actually doing any real work. Let me know if my defs are off.

Anyway any articles/docs/parchment with opinions on this subject you can point me at would be appreciated.

A: 

The only reason you'd ever automate tests is to make things easier to change. If you weren't changing them, you could get away with manual testing. Tying the tests to the database will make the database much harder to change.

Tying them to the NHibernate objects won't help very much either, I'm afraid!

The users of your system won't be using the database or NHibernate. How do they get the benefit (or provide the benefit to other stakeholders)? How will they be able to tell that it's working well? If you can capture that in the Acceptance Tests, you'll be able to change the underlying code and data while still maintaining the value of your application. If someone generates reports from the data, why not generate the same reports and check that their contents are what you expect? If the data is read by another system, can you get a copy of that system and see what it outputs to its users?

Anyway, that's my opinion - keep acceptance tests as close to the business value as possible - and here's a blog post I wrote which might help. You could also try the Behavior Driven Development group on Yahoo, who have a fair bit of experience amongst them.

Oh, and doing integration tests to check that your (N)Hibernate bindings are good is an excellent idea. Saved us on a couple of projects.

Lunivore
So are you saying that acceptance tests should only know about the public interface (Either UI or web services)? For example, adding an invoice. The acceptance test would add the invoice in one page then go look at another page with a list of invoices and make sure it shows up with the correct information? I think what I'm gathering is that acceptance tests would mimic end user interaction.
Mike OBrien
That's the idea, yes. For instance, instead of checking that a particular menu shows up in your menu bar, why not actually use that menu? The user doesn't care if the menu's there, if they can't use it. Also helps encourage devs to produce vertically sliced, end-to-end functionality which engages stakeholders and gets feedback instead of splitting things horizontally and taking months to produce anything.
Lunivore