End to end testing framework for C++ application [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am testing a C/C++ application. For the majority of methods I was able to write unit tests using CppUTest.
But there are a few for which not, and I want to write integration/end to end tests to test these methods too.
What I want to test whether
correct output file is generated
for invalud arguments proper error messages are printed (it is a command line tool)
it displays correct output messgaes
My question is whether there are tools for this, or should I write some scripts to invoke my application, capture output etc.? If yes, how to start these scripts? Invoke them from CppUtest?

I know several ways to test for correct output:
If you use CMake and CTest, you can use CTest to compare the output of your program with the expected output. Does only work for text output (as screen output normally is), and will not work if you output random numbers of time/date and stuff like that. Look for add_test_output_check() in the CMake manuel.
If your program does not write hard-coded to stdout, then you could pass an std::ostringstream and afterwards test the contents of the string using your preferred unit test framework.
Last but not least you could use dup2() to define other file descriptors for stdout and stderr, execute the test and at the end check the contents of the file(s).
For the output file, I guess you have to create a reference output file and then compare the contents of this file with the file that was generated by the test: Write a test function that loads both files and does a memcmp() on the data.

Related

Why does another executable file doesn't give me a hint just like the other one on how parameters in command-line should be formatted? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
In one of my executable file when I try to call it using CreateProcess and passed some parameters in command line the executable file gives me a hint that the parameter should be like this format.
But, when I try to call another executable it doesn't give me a hint. Any idea?
There is no requirement for an application to self document its command line arguments by way of console output or a dialog. Whether or not an application does so is entirely up the the author of that application.
Clearly you have two applications, one which shows a dialog, and one which doesn't. For the latter, presumably you must read its documentation to find out what the arguments should be.
Usage hint depends on the author of the application on how he expose the command-line format. In windows product you can use arguments like: /? -? /help -help
This link will give some information.
https://www.bleepingcomputer.com/tutorials/understanding-command-line-arguments-and-how-to-use-them/

Configuration file format that recognizes comments as a part of config [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am trying to decide which settings format to use for my application.
The config files will be modified from within the application.
The problem is - everything I tried loses comments on file rewrite.
boost::property_tree: JSON, INFO, INI
QSettings
libconfig: YAML
Everything does not treat comments with respect and as the file is written into - they simply vanish. XML would be one option but it is barely human readable and too complex for what I need.
Is there any format/library out there that actually respects comments?
I guess because it's a bit unusual for the program to change a config file in the traditional scheme of things, where the config file is read at start up and can reasonably be considered immutable - at least by the app itself.
You might consider the approach of having a config model which can be 'decorated' with comments and rendered by the program itself. That might give you the option of using the application to create a default config file from scratch if that is of interest to you.
Each time the program starts it would read the config into the internal model, changes could then be made and the decorator / renderer could write it back. You'd probably have to have a template / schema for your model in a seperate file though; otherwise you'd end up having to hard code comments etc which is quite undesirable.

Automated testing: Tool for Visualizing and archiving test results [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have created some automated software tests for a project, which collect the results in a junit xml file structure.
What I am looking for is a web-based tool/solution to display the test results (provided as junit xml files), like what tests have been run, in which time, how many have succeeded, failed, error, skipped,..., in a nice way, with the ability to click on various results/buttons etc. to get additional details or to select a different view on the data (e.g. show me a graphical representation of a given test for the last 10 days...). This database is being updated externally, so only need to store, organize and provide views on the xml file results. No build or internal test execution is required.
If you have any idea of such a tool that would be helpful, otherwise I will update this question to make it more clear what I am looking for, or where to get such information.
P.S. I have looked into using CDash for those purposes, but CDash seem to generate more problems as to use CDash for the purpose of archiving and displaying automated test results.
Teamcity will do just that, and is free up to a limit.
Late to the party, but it seems that Jenkins Continuous Integration is exactly what you ask for. It's free and has a nice web interface.

is there a library can work with input file that contains descriptions and values? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
i'm looking for a library that can do the following :
ask questions and generate an input file
read that input file
while reading the modified input file, the lib assigns the value into the program accordingly to the description in the input file.
i wrote a simple program that does it, like this:
>./main
gaussian width:2
here the program cout "gaussian width" and i input "2". the program also generates parameters.txt file:
gaussian width:2
i can start the program with an existing file:
>./main parameters.txt
it reads the parameter "2" from parameter file and assigns it to int gaussianWidth within the program.
I couldn't find anything like that on the web, so i'm almost done writing one. but i'mm wondering if there is an elegant library like that, for example in boost.
What you are looking for is program options from boost. However you may need to adapt your input file.

What are you using to unit test your C++ code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 months ago.
Improve this question
I'm looking into some possible options for unit testing C++ classes.
So, short and to the point, what are you using?
I'm using cppunit. It is a pretty good port of the iconic JUnit to c++.
UnitTest++. In the past I used Boost Test, which is also pretty good, but I ran across a problem where boost test wanted an operator<< defined and it wouldn't accept my overloaded operator<<. UnitTest++ didn't flinch a bit.
I'm using Google Test
CxxTest, which runs a Perl script as a preprocessor to detect all methods named test*. It's pretty easy to work with, since Perl does all the suite/case registration for you.
Boost.Test. I use boost anyway, might as well use its test library as well rather than yet another different library.
Simple console applications that link the lib / DLL, and use assert statements.
It fits my main requirements: easy to set up, and when an error occurs you can immediately break into the debugger.
To run an individual test repeatedly, the call to the routine is (temporary) copied to the top.
It has some shortcomings, though: First, you don't have an automatic visual verification which tests did run, but that can be fixed with a print statement. You don't get a list of tests that failed. Beyond that, compared to any environment supporting reflection, the added value of unit test frameworks seems a bit low to me. And better these than no unit tests at all.
Have a look at CUnitWin32. It includes an example.