Sorry for the delay in replying, I was busy with JavaOne.
I haven't used C++ in 10 years (saved by Java!) but when I worked at Google (where there was, and still is, a fair amount of C++ code) I remember people using CPPUnit with good results. It has more overhead than JUnit, but it gets the job done. Have you tried the following tutorial?
I should also mention that in addition to using existing tools and automation, developers should consider developing their own "mini"-tools and automation.
xUnit frameworks make some tasks easier, but you can write self-checking tests without them.
Here's a trivial test.
public static testAddition() { int sum = 2 + 2; Assert.assertEquals(4, sum); }
I can write a class Assert with various assert methods. For example:
public void assertEquals(int n1, int n2) { if (n1 != n2) throw new RuntimeException("Test failure. Expected " + n1 + ", but got " + n2); }
Then a simple runner (yes, I'd have to add the tests by hand, but with a bit more code I can take advantage of Java's introspection, scan for tests, and run them automatically).
public void runMyTests() { testAddition(); }
When I execute runMyTests() if an assertion fails, I get a runtime exception with a stack trace.
JUnit offers a lot very nice bells and whistles to make all of this cleaner and simpler, but the essence of a test framework is a library of assertions and a test runner.
> Nice stories about ancient programming teams, and how > things should be done are interesting, but they are of no > help when you can't get the basic tools to work. > > Bill
You might also check this page from Philippe on simple (easy to DIY) frameworks.
This blog entry seems to go over several C++ unit testing libraries. I think the author has his own, called UnitTest++. C# uses NUnit, but I haven't gotten into the .NET stuff yet, so I haven't had occasion to use it.
- Si tu écris du code, écris des tests. - Ne bloques pas sur les dogmes des tests unitaires. - Suis le karma des tests unitaires. - Penses que le code et ses tests n'en font qu'un. - Test est plus important que unitaire. - Le meilleur moment pour tester est quand le code est frais. - Les tests non executés meurent lentement. - Un test imparfait aujourd'hui vaut plus qu'un test parfait demain. - Un mauvais test vaut mieux que rien. - Des fois le test justifie les moyens. - On reconnait le bon ouvrier à ses outils. - Les bons tests échouent.
I took the liberty to replace the "only fools use no tools" with a french proverb which could translated as "one recognize the good worker from its tools". I you prefer the literal translation, it would be "Seuls les idiots n'utilisent pas d'outils". Feel free to use it as you wish.
The poster in french, which could have been found in the ruins of a french subsiduary of your ancient start-up :o) can be found there: http://pantras.free.fr/images/testivus-fr.PNG
>I took the liberty to replace the "only fools use no tools" >with a french proverb which could translated as "one >recognize the good worker from its tools".
I like it!
Thanks again.
Alberto
P.S. I guess I am on the hook for doing the Italian translation :-).
Flat View: This topic has 20 replies
on 2 pages
[
«
|
12
]