Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the C++Test tool in C++

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to use the C++Test tools in C++, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

The C++Test tool allows you to customize the generation of white-box test cases, and at what level (project, file, class, or method) to execute tests, C++Test real-time test coverage, and then create a comprehensive test coverage report, which greatly reduces the programmer's operation.

In addition, if the method under test needs to call a function that does not exist or cannot be accessed at that time, C++Test can automatically generate a stub function; this can test interaction with external resource operations and does not contain any hidden weaknesses. Instead of actually calling these functions, C++Test calls the stub function and returns the value provided by the stub function.

If you need to control the return value used, you can create a pile call table, life input / output relationship. You can also add user-defined pile functions. For example, if you want to use the original function and the function is defined in a different file, or if you want to simulate the behavior of the original function, and the ability to replace it with a simple function to automatically generate the test driver and stub function of the Cmax Cobb + class is unique to C++Test.

Only the C++Test tool can automatically test the Cmax Candle + class (once it can be compiled) without any user intervention. So that you can automatically detect code errors as soon as possible, and find and correct them in the easiest, most economical and fastest way. Without such automation tools, a large amount of time and resource consumption will lose the potential benefits and practical significance of unit testing.

Static test

C++Test embeds more than 700 specifications of Effective C++ (epcc), More Effective C++ (mepcc), meyer-klaus (mk) and Universal Code Standard (ucs), which can be customized by users.

At the same time, it also integrates some specifications accumulated by parasoft. In static testing, C++Test will scan the code in detail to verify whether there is any conflict with these specifications, and find some simple or low-level errors as soon as possible to avoid the spread of integration brought by them.

White-box testing

C++Test provides an effective and efficient way to perform white-box testing. C++Test fully automates all white-box testing processes and automatically generates and executes well-designed test cases. Automatically marks any run failures and displays them in a simple graphical structure. Then these test cases are saved automatically, which can be easily used in future regression testing.

Because C++Test can automatically generate stubs or allow you to add your own stubs, it can test classes that reference external objects. In other words, C++Test can run any class or set of classes and automatically generate and execute a set of test cases designed to find as many errors as possible. C++Test allows you to customize the generation of white-box test cases and at what level (projects, files, classes, or methods) to execute tests.

Black box test

The C++Test tool reduces the burden of black-box testing by automating most of the operations of such tests. In particular, there are two ways to automate the * phase of black box testing-- creating test cases:

Helps you set up the results of each test case.

You can simply enter the test case input and then let C++Test run the test case and automatically determine the actual output. If the result is correct, no other action is required. If the result is incorrect, you can enter the expected output. This is faster and easier than manually entering the results of each test case. Automatically generate a core set of test cases.

The C++Test tool automatically designs a set of broad-spectrum white-box test cases. When using these test cases to test in a black box, you simply observe the actual output and then enter the expected value for any incorrect results.

When you need to enter or modify test cases.

You can simply type the corresponding values in the automatically generated test case framework of C++Test. This will significantly speed up the process of creating test cases. In addition to most of the steps to automate the creation of black box test cases, C++Test fully automates the remaining black box test steps. By pressing a key, you can run one or a group of projects, files, classes, or methods. C++Test then automatically executes all test cases, reports all input / output relationships, and marks any test cases whose actual output is inconsistent with expectations or that causes the program to crash.

regression testing

C++Test fully automates all steps related to regression testing. When you test a class, automatically save its tests and test parameters. When you need to perform regression tests, you can open the appropriate projects and files and run all the original white-box and black-box test cases; C++Test will automatically run exactly the same test cases and parameters and inform you of any problems found. This means that you can immediately know whether any errors have been introduced in the changes.

Monitor test coverage

To help you measure the validity of the set of test cases currently in use and provide you with information to achieve the highest possible coverage, the C++Test tool automatically monitors test coverage. C++Test follows the test coverage in real time, and then creates a comprehensive test coverage report.

The coverage window graphically shows the lines of code that are currently being executed, the lines that have been executed, and the number of times each line has been executed. Therefore, it indicates not only whether a line of code has been tested, but also how thoroughly it has been tested. This information is very helpful in determining which code requires additional tests.

After reading the above, have you mastered how to use the C++Test tool in C++? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report