

Ask HN: What do you use to Unit Test your Web app? - aik

I've been working on a web-app with a team for the past 2 years, and we are trying to move into a fully continuous integration model.  Currently we have no unit tests - however our app is fully tested and we have a good amount of happy live clients.  We are at a point where it's becoming increasingly important that we maintain a well working system with each update.<p>- I'm curious what test harness you would recommend?
- For a web-app, what exactly do you test and what do you skip?
- How do you structure the tests?  Do you break it into separately testing the UI, data objects, helper classes, etc. - or do you do functional testing and just test specific features?
- Do you unit test your web app?  Why, why not?<p>Our app is (unfortunately) in ASP.net/C#, but runs well and development has been quick.<p>I would appreciate any feedback.
======
AmberS
NUnit is a MUST. I wonder why you say unfortunately. I realize it's not the
most popular thing on the HN block but if you're not proud of your codebase,
it's never going to work.

Since you have NO automated tests, start this way: 1) Every single time
someone fixes a bug or adds a new feature, they MUST have at least one
automated test that "proves" this functionality is correct 2) In your "spare"
time, you can also write automated tests to test the code execution paths
covered in your manual tests that I assume you run

As for what to skip, at the beginning: nothing. Try testing -everything- you
touch. You need all you can to get some real regression testing in. Eventually
when you are at 50-70% code coverage you will be in a position to know what
are the high-value things to cover and maybe pick and choose (although
probably not).

------
lox
I couldn't live without test driven development, lets us ship code quickly.

We have a large test suite using SimpleTest for testing the PHP side of things
on 99designs, along with a custom web-based test runner. Only problem is our
full test suite now runs at over 4-5 minutes. 90% of the time is taken up with
setting up a fresh database environment before each test. Interested to hear
how everyone else handles this.

~~~
rubinelli
My team tests the data access layer separately, rolling back after each
individual test, then mocks it out for the rest of the tests.

------
honopu
I too wonder this question. I have a CMS based php/mysql app where essentially
every object derives from the db. Aside from ensuring type in function args
and doing some instanceof's, i feel like I'll eventually have more of these
issues creep in as the scope of the app increases.

I am pretty diligent with testing, but sadly I am only human.

~~~
aik
I'm fairly sure we're going to go with Selenium and start on tests to automate
base functionality. To keep sane we'll stay away from fringe cases and make
tests as simple as possible. With a majority of the user base and
functionality protected, we should be fine by continuing running basic manual
tests for new functionality, and relying on users to find special issues that
could be introduced over time that we miss.

------
MPiccinato
Check out NUnit. Rhino Mocks is also good for mocking.

Are you using Webforms or MVC? Just out of curiosity.

------
nreece
NUnit and TypeMock are pretty popular for .NET/C# code.

