Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: C unit testing and regression testing |
| Date | 2013-08-14 21:53 +1200 |
| Message-ID | <b712dkFlukaU5@mid.individual.net> (permalink) |
| References | (2 earlier) <ku23uj$p3t$1@dont-email.me> <slrnl09m2o.2m9.grahn+nntp@frailea.sa.invalid> <kud68v$20c$1@dont-email.me> <b6vrvqFlukaU4@mid.individual.net> <kufidm$ti3$1@dont-email.me> |
James Harris wrote: > "Ian Collins" <ian-news@hotmail.com> wrote in message > news:b6vrvqFlukaU4@mid.individual.net... >> James Harris wrote: >>> >>> I find such things much easier to read if they can be expressed on one >>> line. >>> That's particularly true where there is a series of tests one after the >>> other without any code in between. That helps to see differences between >>> tests and to spot if any are missing. >> >> Having multiple test cases in one test function is generally not a good >> idea. It makes spotting the actual failure harder unless you are very >> careful with your failure reports. > > I can't quite see this. If we wanted to test the response of a function to > certain inputs wouldn't it be best to group those test cases together as in > > check that func(1,2,3) returns 4; > check that func(9,10,11) returns 8; > check that func(7,0,7) returns -1; > etc It sometimes is (especially if you are retrofitting tests) and it isn't too bad if you can easily tell which of the conditions failed in the test output. One drawback is with the frameworks I've used, if the first condition fails, the whole test function fails and you end up with more test/fix cycles than you would with smaller tests. When writing test first, you tend to build up small incremental tests. >>> Do you guys have any good way of testing such composites? Or do you just >>> check each item individually? Say you had an array which, at some point >>> in >>> the tesing, should have two or three elements with specific values. Would >>> you just write a check for each element or do you have a more clever way >>> of >>> testing such things? >> >> With CppUnit (and I assume other test frameworks) you can define your own >> equivalence operator for a given type. > > Maybe I should look at CUnit (though I don't think anyone has recommended > it). Or perhaps I should learn some C++ and try CppUnit. From comments on > this thread it looks like it could be used to test C code. However, I am > somewhat reticent to start getting into C++ at the moment. You don't have to learn that much C++ to get going. I think most C programmers would be happy with it. I have used writing unit tests for C as a good way of introducing C++ to C programmers. Way back testing C was how I first learned C++. The IDE I use these days (NetBeans) has good support for working with both C and CppUnit tests. So the programmer just writes test cases and the IDE does the boilerplate. I haven't tried CUnit. -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-08 17:46 +0100
Re: C unit testing and regression testing James Kuyper <jameskuyper@verizon.net> - 2013-08-08 13:29 -0400
Re: C unit testing and regression testing Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-08-08 11:49 -0700
Re: C unit testing and regression testing James Kuyper <jameskuyper@verizon.net> - 2013-08-08 16:33 -0400
Re: C unit testing and regression testing Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-08-08 14:55 -0700
Re: C unit testing and regression testing James Kuyper <jameskuyper@verizon.net> - 2013-08-08 18:35 -0400
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-09 07:34 +0100
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-09 18:08 +1200
Re: C unit testing and regression testing Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-08-09 03:16 -0700
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-09 18:04 +1200
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-09 07:30 +0100
Re: C unit testing and regression testing Les Cargill <lcargill99@comcast.com> - 2013-08-08 12:54 -0500
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-09 07:37 +0100
Re: C unit testing and regression testing Les Cargill <lcargill99@comcast.com> - 2013-08-09 07:46 -0500
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-08 18:55 +0000
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-09 07:58 +0100
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-09 19:54 +1200
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-13 12:35 +0100
Expect (was Re: C unit testing and regression testing) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-13 19:10 +0000
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-09 11:54 +0000
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-13 12:45 +0100
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-13 19:50 +0000
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-14 10:14 +0100
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-14 19:44 +0000
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-15 13:10 +0100
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-17 07:32 +0000
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-14 10:58 +1200
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-14 10:25 +0100
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-14 21:53 +1200
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-09 07:17 +1200
Re: C unit testing and regression testing Bart van Ingen Schenau <bart@ingen.ddns.info.invalid> - 2013-08-09 10:30 +0000
Re: C unit testing and regression testing Ian Collins <ian-news@hotmail.com> - 2013-08-10 08:21 +1200
Re: C unit testing and regression testing <william@wilbur.25thandClement.com> - 2013-08-08 13:37 -0700
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-08 22:52 +0000
Re: C unit testing and regression testing "James Harris" <james.harris.1@gmail.com> - 2013-08-09 08:17 +0100
Re: C unit testing and regression testing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-09 09:34 +0000
Re: C unit testing and regression testing Les Cargill <lcargill99@comcast.com> - 2013-08-09 07:52 -0500
Re: C unit testing and regression testing Siri Cruise <chine.bleu@yahoo.com> - 2013-08-09 05:29 -0700
Re: C unit testing and regression testing Roberto Waltman <usenet@rwaltman.com> - 2013-08-11 20:19 -0400
Test-driven development (was Re: C unit testing and regression testing) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-17 07:17 +0000
Re: Test-driven development (was Re: C unit testing and regression testing) Ian Collins <ian-news@hotmail.com> - 2013-08-17 19:40 +1200
Re: Test-driven development (was Re: C unit testing and regression testing) Les Cargill <lcargill99@comcast.com> - 2013-08-17 11:40 -0500
csiph-web