PDA

View Full Version : Testing?


jemfinch
06-06-2002, 01:49 PM
So does anyone here use any testing methodology in their O'Caml code? I'm looking to start coding on my SML IRC bot in a week or so (after exams are done :)) and will want to integrate testing into my code base. I'm curious how other people automatically test their code.

If anyone hasn't looked, there's http://www.sf.net/projects/fort/ , a framework for testing O'Caml code. I might try to mimic aspects of that code, but there are some things I don't like: I don't like that Fort compiles the testing code separately; I think it should be compiled with the application and executable on demand, so a change in the program that affects testing code is found out before the program can ever compile.

Anyway, what testing methodologies (if any) do you people use?

Jeremy

GnuVince
06-06-2002, 04:00 PM
I normally write simple enough programs that I can test them myself manually. If I were writting bigger applications, I would probably #use the source file in top-level loop and test each function individually with correct and incorrect arguments to see how it reacts. Of course, in a large project, I don't know how I'd do it; I never heard of testing units, do they send all sort of data to a program and see if it crashes?

And why are you going to SML by the way?

file13
06-06-2002, 06:14 PM
he he, i beg for help.... ;)

nope, never tried it. is it actually stable and they forgot to update thier peoject summary?

but yeah, testing via the toplevel is very helpful and one of my favorite things about Ocaml. other then that i try to make sure the design is a general as possible for code reuse. then i simply run it a shit load of ways trying to get it to crash--like runnins gui progs without X, too much input. putting spaces and odd caracters.

but formal methodologies? i'd check out the Extreme Programming:

http://www.extremeprogramming.org/

good luck and if you need testers try begging for help.... :D

jemfinch
06-07-2002, 12:08 AM
file13, Gnu/Vince: I'm talking more about automated testing. The kind of testing you do to make sure that when you refactor your program you don't break things. For that, you need a consistent programmatical way to do your testing, not just some personal interaction with the toplevel :)

Jeremy

GnuVince
06-07-2002, 12:15 AM
/me knows not. I test myself. And how does a framework test unit work? Couldn't find concrete information on Google (eek!)

Strike
06-07-2002, 10:36 AM
GnuVince, you can look at the Python "unittest" module for an example of regression test framework.

jemfinch - did you ever use that module (the unittest module) when you were blazing through Python? If so, would that sort of thing be good enough for what you need?

GnuVince
06-07-2002, 12:13 PM
Strike, I'm not looking for an example: I want to know what a unit test framework is in theory. A definition.

jemfinch
06-07-2002, 12:53 PM
Strike: Yeah, I've looked at PyUnit and JUnit. They're much more oriented to class-based OOP, however, and thus not directly applicable (or translateable) in SML.

GnuVince: Well, first you have to understand a test. A test is a way of testing a function to make sure that, given a certain input, a certain output results. Each function could have several tests, testing all kinds of error conditions and boundary conditions and so on. A testing framework is something to make these tests automated, so you can compile and then run all the tests you accumulated, and see if your code breakage broke anything. If I have a set of tests that my code is supposed to pass, and I change something and then it doesn't pass some tests, then I know my code has been changed in some negative way as to produce misbehavior. A testing framework makes it such that these tests can be run with a simple command, and the results of all the tests can be seen at a glance.

The point of tests is to save time debugging. It's to make it so that each incrememental change to a program doesn't introduce more bugs into the program than it fixes. It's important to have a high-quality testing framework in order that you save more time in reduced bugs than you do in the actual testing.

Jeremy

GnuVince
06-07-2002, 02:35 PM
jemfinch: If I get you right, the programmer writes a serie of tests that a function must pass. These series are then tested against the given functions. Do I get it about right?

Strike
06-07-2002, 05:19 PM
GnuVince, I wasn't JUST trying to give you a framework. If you go and look at the documentation on the Python unit test module, it does explain what it does you know.

jemfinch
06-08-2002, 02:37 PM
Yes, GnuVince, that's about it.

Jeremy