Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #138153

Unit test in C and breaking dependencies

From pozz <pozzugno@gmail.com>
Newsgroups comp.lang.c
Subject Unit test in C and breaking dependencies
Date 2018-11-20 14:22 +0100
Organization A noiseless patient Spider
Message-ID <pt11qe$es$1@dont-email.me> (permalink)

Show all headers | View raw


I couldn't understand if the module under test is compiler two times: 
one for production code and the other for the test. I think it would be 
better to compile it only one time, for production code *and* tests. So 
you are sure you are testing the code that really will be in production.

So I think it should be better to link the test executable with the same 
object files generated during normal build for production code.
One suggestion I read is to create a static library with all object 
files. The production executable and test executable are created linking 
this static library.

This approach can be used to break and replace dependecies of a module 
under test. Indeed, if you specify the test doubles (replacing modules) 
before static library to the linker, it will use the test doubles 
instead of real modules.

Is it your preferred method? Are there other better ways?

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Unit test in C and breaking dependencies pozz <pozzugno@gmail.com> - 2018-11-20 14:22 +0100
  Re: Unit test in C and breaking dependencies James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-11-20 09:07 -0500
  Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-21 04:38 -0800
    Re: Unit test in C and breaking dependencies Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-11-21 12:59 +0000
      Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-21 05:35 -0800
        Re: Unit test in C and breaking dependencies Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-11-21 20:50 +0000
          Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-22 04:10 -0800
            Re: Unit test in C and breaking dependencies Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-11-22 15:30 +0300
              Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-22 04:44 -0800
            Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-22 04:35 -0800
            Re: Unit test in C and breaking dependencies Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-11-22 17:08 +0000
              Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-23 03:08 -0800
                Re: Unit test in C and breaking dependencies Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-11-24 05:51 +0000
                Re: Unit test in C and breaking dependencies Chad <cdalten@gmail.com> - 2018-11-24 03:35 -0800
                Re: Unit test in C and breaking dependencies Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-11-24 12:50 +0000
                Re: Unit test in C and breaking dependencies Chad <cdalten@gmail.com> - 2018-11-26 07:20 -0800
                Re: Unit test in C and breaking dependencies Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-11-27 14:32 +0000
                Re: Unit test in C and breaking dependencies Ian Collins <ian-news@hotmail.com> - 2018-11-28 15:18 +1300
            Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-29 09:16 -0800
        Re: Unit test in C and breaking dependencies Wouter Verhelst <w@uter.be> - 2018-11-23 09:21 +0100
          Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-23 03:16 -0800
            Re: Unit test in C and breaking dependencies Thiago Adams <thiago.adams@gmail.com> - 2018-11-23 03:18 -0800
            Re: Unit test in C and breaking dependencies Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-11-23 15:27 +0300
              Re: Unit test in C and breaking dependencies Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-11-23 06:42 -0800
  Re: Unit test in C and breaking dependencies Ian Collins <ian-news@hotmail.com> - 2018-11-28 15:24 +1300

csiph-web