Live data from Hacker News

Ask HN: How do people really test their code?

news.ycombinator.com

1–10 of 29 posts

Ask HN: How do people really test their code?

#1
If that question is too general, which it is, then consider the case of building a data structure and its accompanying algorithms. Now, how, IRL, is code verified both for correctness and for desired performance.

Right now, I rely on running a bunch of functions that I write, but I was wondering if there's anything out there that's better (or sort of a methodology that dictates which tests one ought to write).

(if the question is still too general, lets consider the case for Java, and maybe C).

Re: Ask HN: How do people really test their code?

#4
post #3
post #2

No no, let's keep it general, please.

I know you! you're the guy that wants to take the good advice and use it elsewhere! ^5s

OK, I'll bite. 'Code' for me, at the moment, is a web app in beta that needs functional and cross-browser UI testing.

So until I script all flows into Selenium, twill, windmill or something else, and until I can figure out how to automate screenshots of all screens in the OSs and browsers I care about (http://stackvm.com ?), I have checklists, and I go through them manually.

It helps that my web app's UI is short and sweet, but that's probably because I'm trying to avoid thinking about the combinatorial explosion it's hiding.

Re: Ask HN: How do people really test their code?

#5
In order of decreasing importance, I recommend you: Constantly check that you're building the right thing. Get some kind of testing framework. Look into Test Driven Development as a methodology.

With a testing framework, you won't waste time rolling your own. For Java, you could start with JUnit.

TDD is a formalized approach to writing test functions as you work, which you already do, while simultaneously designing your code. There are many sources on it around the internet, but Kent Beck's book took the magic out of it (a good thing) for me: http://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0...

Of course, there are many other specific techniques you can use to test that your algorithms do the right thing, all dependent on what you've made. Regardless, I try to make sure that the a real user gets their hands on an up to date build as often as possible, and they're sure to show me all of the ways that my software is technically excellent, yet in no way solves their actual problem.

Re: Ask HN: How do people really test their code?

#6
post #5

In order of decreasing importance, I recommend you: Constantly check that you're building the right thing. Get some kind of testing framework. Look into Test Driven Development as a methodology. With a testing framework, you won't waste time rolling your own. For Java, you could start with JUnit. TDD is a formalized approach to writing test functions as you work, which you already do, while simultaneously designing y…

Also, please check out 'Behavior Driven Development's or BDD, which is basically "TDD done correctly." It alters the description of the process a bit, and in the end, you write better tests.

Since I'm a Rubyist, I use Cucumber and RSpec to do testing. http://cukes.info http://rspec.info (note that you can use cucumber to test any language, and I bet you could use JRuby to test java.

Re: Ask HN: How do people really test their code?

#7
I'm interested in what you mean by the 'really' in the title. Do you think there's some kind of secret to how people test that they're not revealing?

If you want to see some 'IRL' test code, have a look at your favorite open source project. The test code will all be there, usually in a folder just off the root called 'tests/'.

Re: Ask HN: How do people really test their code?

#8
post #4
post #3

Earlier quoted context omitted.

I know you! you're the guy that wants to take the good advice and use it elsewhere! ^5s

OK, I'll bite. 'Code' for me, at the moment, is a web app in beta that needs functional and cross-browser UI testing. So until I script all flows into Selenium, twill, windmill or something else, and until I can figure out how to automate screenshots of all screens in the OSs and browsers I care about ( http://stackvm.com ?), I have checklists, and I go through them manually. It helps that my web app's UI is short an…

Check out http://browsershots.org/

Re: Ask HN: How do people really test their code?

#9
post #4

Earlier quoted context omitted.

OK, I'll bite. 'Code' for me, at the moment, is a web app in beta that needs functional and cross-browser UI testing. So until I script all flows into Selenium, twill, windmill or something else, and until I can figure out how to automate screenshots of all screens in the OSs and browsers I care about ( http://stackvm.com ?), I have checklists, and I go through them manually. It helps that my web app's UI is short an…

Check out http://browsershots.org/

Thanks, I've used that before but I meant with cookies, etc.

Re: Ask HN: How do people really test their code?

#10
post #4
post #3

Earlier quoted context omitted.

I know you! you're the guy that wants to take the good advice and use it elsewhere! ^5s

OK, I'll bite. 'Code' for me, at the moment, is a web app in beta that needs functional and cross-browser UI testing. So until I script all flows into Selenium, twill, windmill or something else, and until I can figure out how to automate screenshots of all screens in the OSs and browsers I care about ( http://stackvm.com ?), I have checklists, and I go through them manually. It helps that my web app's UI is short an…

check out http://saucelabs.com/! Write your scripts with Selenium RC, run them against any browser, and get screenshots of every important steup.
Post reply on HN