Can any IDE or framework quickly test new code without having to run the entire application

I mainly develop in native C ++ for Windows using Visual Studio.

Many times I find myself creating a new function / class or something else, and I just want to test this piece of logic that I just wrote quickly.

Many times I have to run the whole application, which sometimes can take some time, since there are many related parts.

Is there any tool that will allow me to quickly test this new code without having to run the entire application?

i.e.

Let's say I have a project with about 1000 files, and I'm adding a new class called Adder. Adder has an Add (int, int) method;

I just want the IDE / tool to let me test only the Adder class (without having to create a new project and write a dummy main.cpp), letting me specify the value of the inputs coming into the Adder object, Similarly, it would be nice if that would allow me indicate the expected result from the test object.

What would be even colder is if the IDE / tool then writes these sets of inputs / expected output and automatically creates an element tester class on it. If I added more I / O sets, it would continue to build I / O history.

Or how about this: that if I launched the actual application, I gave it some real data and checked that the IDE / tool captures everything that comes into the device under test. Thus, I can quickly restart my testing if I find some errors in my program, or I want to change its interface a little. I think this feature will be so neat and can help the developer quickly test / modify their code.

Am I talking about testing a fraudulent object / module that already exists?

Sidenote: It would be great if the Visual Studio debugger had “snooze” technology where the user could go back to find what went wrong. Such a debugger already exists here: http://www.totalviewtech.com/

+4
source share
4 answers

It is very easy to start with static unit testing in C ++ - three lines of code .

VS is a little poor in that you need to go through the wizards to create a project to create and run tests, so if you have a thousand classes, you will need a thousand projects. Therefore, for large projects on VS, I usually organized a project in several DLLs for self-construction and testing, and not for monolithic ones.

An alternative to static tests, more similar to your "poke and dribble" script, can be executed in python, using swig to bind code to the interpreter and python doc tests . I have not used both together. Again, you'll need a separate goal to create a python binding, and another to run tests, and not just a simple “run this class” button.

+2
source

I would go with Boost.Test (see the tutorial here )). The idea would be to add a new configuration to your project that would preclude the collection of all unnecessary cpp files. You just need to add .cpp files to describe the tests you want to pass.

I am not a specialist in this field, but I have used this technique in the past and it works!

0
source

I think you are talking about unit testing and mock objects. Here are some open source C ++ object libraries that might be useful: -

0
source

Basically you ask how I can test one function instead of the whole application. This is what unit-testing is, and you will find many questions about unit testing C ++ on SO.

0
source

All Articles