automated unit test generation

S

skunkwerk

Hi,
I've been working on an open source project to auto-generate unit tests for web apps based on traces collected from the web server and static code analysis. I've got an alpha version online at www.splintera.com, and the source is at https://github.com/splintera/python-django-client. I'd love toget some feedback from the community and extend it to work with other languages as well.

I wrote it originally because I was sick of coming into companies where Ihad to inherit tens of thousands of lines of code without any tests, and never had time to write them manually - being careful to mock out dependencies, specify the correct inputs and outputs, and figure out which path it was taking through the code.

I'd like to get some sense of:
- how difficult/tedious is writing unit tests, and why?
- do you wish you had better code coverage?
- how important is testing to you?

thanks,
imran
 
P

Paul Rubin

skunkwerk said:
- how difficult/tedious is writing unit tests, and why?

The important thing is to write the tests at the same time as the code.
If you do that, it's not too bad. It means the code is then organized
around the tests and vice versa. Keeping tests in sync with changes to
code can be annoying and it's easy to let that slip under schedule
pressure. After that happens enough, you've got a non-TDD program.

Writing tests for code that's already been written without automated
testing in mind is much more difficult and tedious. Automatically
generating tests for already-written code also seems dubious.

Also, unit tests themselves are fairly easy, but often you also have to
write mock objects to run the tests on and interpret the results.
That's actually taken more thought when I've done it. I haven't used
the new Python framework for it yet though.
- do you wish you had better code coverage?

Sure, we could all use that. On the other hand it slows down
development if you overdo it. It's a trade-off like anything else.
- how important is testing to you?

If you mean TDD and automated testing, it's very helpful if you're doing
something intricate, or if it needs frequent changes and redeployment,
etc. For more straightforward tasks, manually testing while you code is
ok, especially if it's the type of code for which smoke testing is
enough to tell whether the code works. So like anything else, it's a
trade-off based on the features and priorities of the task at hand.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top