CxxTest plugin for Netbeans

Hi, do you have a cxxtest plugin for Netbeans?

Groups:

Comments

Stephen Edwards

No, sorry, we don't have any

No, sorry, we don't have any CxxTest support for NetBeans.  There is a Web-CAT submission plug-in for NetBeans, I think.  If anyone wants to work on CxxTest support for NetBeans, the Java source to the Eclipse plug-in is available on-line.  I can point you to where, if you need it.

Ian Hickey

CxxTest on Netbeans HOW-TO

I realize this is a really old thread. I'm posting this only for future visitors that might be looking into this topic. In the following, I outline how to setup cxxtesting in Netbeans as well as the required MinGW and Perl. At one point, I reference a "template" that the student can use. That template is literally just a Netbeans template that I made to replace the classname being tested (by whatever the student chooses) so the student didn't completely have to start from scratch. A cursory look at the CxxTesting site will provide roughly the same. And the Netbeans version of the submission plugin works great.

Disclaimer: I was tired when I wrote this;>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Setting up the Required Software for CxxTest

 

Installing Cxxtesting for use with NetBeans IDE:

*This document assumes the user is installing cxxtest on Windows 7, using the default directories for MinGW and ActivePerl.

If using any directories other than these, you will have to modify these instructions accordingly.

 

Instructions on installing Cxxtesting using the MinGW Compiler

Step 1 Install MinGW: If you haven’t done so, install the included program MinGW into the directory c:\MinGW.

After the installation is complete, install the included program MSys into the c:\msys directory.

Step 2: Unzip the included file cxxtest3.10.1into the c:\MinGW directory. Once completed, your directory structure should look like this:

C:\MinGW\cxxtest

…Directory/cxxtest

...Directory/doc

...Directory/sample

...Other Files

 

Step 3 Libraries: Navigate to the C:\MinGW\cxxtest directory and copy the cxxtest directory

(c:\MinGW\cxxtest\cxxtest\) and paste it into the directory c:\MinGW\include.

Your directory structure should look like this:

C:\MinGW\include\

...Directory/cxxtest

...Directory/ddk

...Directory/driverlib

...Other Directories and Files

 

Step 4 Path Settings: You will need to add and make sure your Windows PATH contains the needed entries. If you installed MinGW and cxxtest, add the entry

“;c:\MinGW\bin and ;c:\MinGW\cxxtest” to your path and restart your computer. You can make sure that the PATH is set correctly by type “cmd” into the start menu, and typing g++ at the command prompt. If you receive the message “g++ fatal error:

“no input files”, the PATH is correctly installed.

 

Step 5: Using the included ActivePerl installer, Install Perl in the default C:\Perl64 directory. Make sure during the installation that the option “Add PATH” is selected. You can verify correct installation by going into a command prompt and type Perl version.

If you receive the version information everything is working.

Installing and using the cxxtest template

Install the template in Netbeans

 

Step 1: Open Netbeans and navigate to Tools followed by Templates.

Step 2: Click the C++ folder and then the Add option.

Step 3: When the file dialog opens, navigate to where you saved the

CxxTestInstallInstructions folder and locate the file named ‘classnameTest’.

Once the new template appears, click the ‘rename’ button and rename the file

‘New Cxx Test’.

The template is now installed and ready to use.

 

Accessing and using the Template

To use the newly installed template:

 Right click the header folder of the project where you would like to test.

Click ‘New’ and ‘Other’ followed by C++ and choose the ‘New Cxx Test’ file that you previously installed. Choose a name for your test file. You should use the class name that you are testing followed by the word Test. For example, if you are testing the Clock class, you would use ClockTest.h as the name. Click Finish. When the file opens you will see the following and you can begin creating tests.

/*

* File: filenameTest.h

* Author: NAME

*

* Created on DATE, TIME

*

* This file uses the CxxTest library <TestSuite> to create test cases

* for a students project. For full cxxtest documentation see the userguide

* located in your C:\MinGW\cxxtest\doc or visit:

* http://cxxtest.com/guide.html

*/

#ifndef FILENAME_H

#define FILENAME_H

#include <cxxtest/TestSuite.h>

//Include your class’s header file(s) below and uncomment. For Example:

//#include "myClass.h"

class NAME : public CxxTest::TestSuite {

public:

//All tests should start with the word 'test' followed by

//the name of the function being tested.

void testMyFunction() {

//Use TS_ASSERT_EQUALS(Result, ExpResult) to test your functions.

}

#endif /* CLOCKTESTTWO_H */

* For detailed instuctions on cxxtests, please see the user guide

* located in your C:\MinGW\cxxtest\doc folder or visit: http://cxxtest.com/guide.html

 

Running Tests

Running tests from the command line (not recommended, use netbeans instead)

Suppose you have a project that contains three file: Clock.h, ClockTest.h, and Clock.cpp

myClassTest.h would be the file you created using the Netbeans New Cxx Test Template.

To run the tests the first thing we need to do is generate a test file that can be compiled. We do this using the Perl Script named ‘cxxtestgen.pl’ located in the folder c:\MinGW\cxxtest\

To run our tests from the command line, first open the command prompt by type ‘cmd’ into the start menu. Next, navigate to you Netbeans project directory that contains the above files.

c:\>cd c:\users\user\documents\NetBeanProjects\class\

Next, Generate the test runner file using:

c:\perl c:\\MinGW\\cxxtest\\cxxtestgen.pl --errorprinter –o runner.cpp ClockTest.h

You can verify that the runner.cpp was generated by doing a directory listing:

c:\dir

Next generate the runner test file executable:

c:\g++ runner.cpp Clock.cpp Clock.h o

runner.exe

Finally, Run the .exe to see your test results.

c:\runner

Editing your make file to automatically run tests on each build

 

The last section explained how to run your tests from the command line.

Much more likely, you want to run your tests from inside NetBeans automatically. The process is the same as above, except instead you will simply add the commands into your Makefile and have NetBeans execute them everytime you build your project. Using the same example as above:

Step 1: Expand the ‘Important Files’ directory in your project and open the ‘Makefile’ in your editor.

Step 2: Locate the “.buildpre:” line and add the following three lines so that your makefile looks like this:

.buildpre:

# Add your pre 'build' code here...

        perl c:\\MinGW\\cxxtest\\cxxtestgen.pl –errorprinter –o runner.cpp ClockTest.h

        g++ runner.cpp Clock.cpp Clock.h –o runner.exe

        ./runner.exe

 

*Special care is required when editing a makefile. The (above) Indented lines must be indented by two tab stops rather than one otherwise you could receive an error message that you are “Missing a separator”.

Once the MakeFile is edited, your tests will run and the results displayed in the Netbeans console every time you Build your project.

***Beware that the generated runner files need to be deleted BEFORE submitting this project to Web-CAT otherwise you will receive a suspended assignment.