Menu

CppUnit 1.9.11 under KDevelop 2.1.5

Help
2003-10-29
2003-11-17
  • Joachim Käßer

    Joachim Käßer - 2003-10-29

    Hello everybody,

    i'am using CppUnit v1.9.11 portability-test4 under S.u.S.E.-Linux 8.2. with KDevelop 2.1.5 .

    Because im new to Linux/cppunit i have a question regarding using qttestrunner.

    Building the sources seams to be no problem. The library "libcppunit.*" is installed in the right place (this is "/usr/local/lib").

    Trying the Examples is also OK with the Execption when using the qttestrunner. The lib seems to contain no implementations specific to qttestrunner.

    It should be possible to build a library out of the sources in "qttestrunner" that will provide the QtTestRunner implementation.

    Because if have no tmake/nmake on my system, i tryed to write an automake.am file for the qttestrunner-subfolder and integrated the generated Makefile.in in the config.in of the top-builddir.

    After that i could generate a new "configure"-script wich could be executeted without any errors.

    The build-process, i have started with "make", stops when it is trying to compile the file "QtTestRunner.cpp". "QtTestRunner.cpp" includes "TestRunnerDlgImpl.h" wich itself includes "testrunnerdlg.h". But the file "testrunnerdlg.h"
    is missing. There is a MS-specific version in the "msvc6" folder but i think this couldn't be the source that has to be included. "TestRunnerDlgImpl.h" instead is derived from a class "TestRunnerDlgBase" wich is also missing.

    Could someone give me a hint how to build a fully functional library including qttestrunner?

    With best regards,
    J.Kaesser.

     
    • Joachim Käßer

      Joachim Käßer - 2003-10-30

      So it was just that simple:

      - go to the top-builddir (e.g. '~/cppunit') and edit the file 'configure.in'
      - add the following line in the AC_OUTPUT macro (just the next line after 'src/cppunit/Makefile \'): 'src/qttestrunner/Makefile \'
      - go to the sourcedirectory (e.g. '~/cppunit/src') and edit the file 'Makefile.am'
      - add ' qttestrunner' to SUBDIRS
      - go to the 'qttestrunner' subfolder
      - type 'qmake -o Makefile testrunnerdlg.pro'
      - go back to top-builddir
      - generate a new configure-script with 'autoconf'
      - execute the script with './configure'
      - build the libraries with 'make' -- we don't need to call 'automake' first, because 'qmake' has created the 'Makefile' already
      - both libraries 'libcppunit.la' and 'libqttestrunner.so' are now created (the libcppunit.la is in the hidden directory '.libs' and libqttestrunner.so is visible in '~/cppunit/lib')
      - log in as root with 'su root'
      - type 'make install' -- this will install only the libtool-library 'libcppunit.la' to '/usr/local/lib'
      - to install the testrunner-lib type 'cp libqttestrunner.so*' /usr/local/lib'
      - type 'exit'

      I would like to make a suggestion for the next cppunit-release:
      For a better integration of the build-process under linux, please provide a 'Makefile.am' for qttestrunner,
      so that the 'libqttestrunner.la' libtool-library is installed automatically by the autotool-scripts.

      With best regards,
      J.Kaesser.

       
      • Anonymous

        Anonymous - 2003-11-07

        Thanks a lot for the info. I've managed to build my qttestrunner now. However when I run I get 'QPaintDevice: Must construct a QApplication before a QPaintDevice'. This is unit cppunit-1.9.11. I'm assuming you didn't get this?

        Anyone know how to fix?

         
    • Joachim Käßer

      Joachim Käßer - 2003-11-07

      This sounds to me like a problem with your Qt-Application rather than a cppunit-problem.

      I guess you've tried to start qttestrunner before you have initialized the underlying QApplication.

      If i am wrong, please let me know how your QApplication is structured and how it integrates qttestrunner.

      With best regards,
      J.Kaesser

       
      • Anonymous

        Anonymous - 2003-11-10

        I've literally got

        #include <cppunit/extensions/TestFactoryRegistry.h>
        #include <cppunit/ui/qt/QtTestRunner.h>

        /** Run all the tests
        */
        int main() {
            CppUnit::QtUi::TestRunner runner;
            CppUnit::TestFactoryRegistry &registry =
                CppUnit::TestFactoryRegistry::getRegistry();
            runner.addTest(registry.makeTest());

            runner.run( false);
        }

        Am I missing something?

         
        • Joachim Käßer

          Joachim Käßer - 2003-11-17

          Hello Rob,

          as far as i know, the qttestrunner isn't a standalone application.
          That means that you have to provide a QApplication object by yourself in the main function.

          The following code is part of the qt-example of the cppunit-distribution.
          The body of the main-function first defines a QApplication-object, wich is
          initialized with the commandline-parameters.

          After that, the testrunner is defined, the testsuite is added and the test
          is started.

          #include <qapplication.h>
          #define QTTESTRUNNER_API __declspec(dllimport)
          #include <cppunit/ui/qt/TestRunner.h>
          #include <cppunit/extensions/TestFactoryRegistry.h>

          int main( int argc, char** argv )
          {
              QApplication app( argc, argv );

              CppUnit::QtUi::TestRunner runner;
              runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
              runner.run( true );

              return 0;
          }

          If you want to test your commandline-application, i think its better to
          use the text-only version of the testrunner.

          There is an alternativ to cppunit. The library is called "qtunit" and is also based on the original JUnit-port by Michael Feathers. But "qtunit" have the following advantages for unix/linux-developers:
          - qt3.x-based library
          - text and gui-version
          - standalone qt-testrunner already provided in the examples
          - don't use macros like cppunit
          - fewer classes, easier to learn
          - mainly developed under unix not windows

          there are still some disadvantages:
          - needs qt-library with enabled thread-support
          - not so far evolved (still version 0.9.8)
          - not widly known (compared with cppunit)

          if you are interested, i can send you the URL where you can download qtunit.
          Since i have big problems using the cppunit ASSERT-macros under S.u.S.E.-Linux, qtunit is my favourite.

          With best regards,
          J.Kaesser

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.