为什么两个"Start (Without) Debugging"(F5 和 Ctrl+F5)都不创建 CppUnit *.xml 报告文件?
Why both "Start (Without) Debugging" (F5 anf Ctrl+F5) doesn't create CppUnit *.xml report file?
首先,我想欢迎大家加入stackoverflow,因为这是我的第一个问题
我在VisualStudio2005上使用CppUnit生成输出*.xml文件时遇到了麻烦。当我用F5或Ctrl+F5("开始调试"或"不调试就开始")运行代码时,它不会创建报告文件。但当我"手动"运行它时(通过/debug中的*.exe文件),报告文件就会创建。原因可能是什么?
testApp.cpp:
#include "Test_myFuzzy.h"
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/XmlOutputter.h>
int main(){
CppUnit::TextUi::TestRunner runner;
std::ofstream ofs("tests.xml");
CppUnit::XmlOutputter* xml = new CppUnit::XmlOutputter(&runner.result(),ofs);
xml->setStyleSheet("report.xsl");
runner.setOutputter(xml);
runner.addTest(Test_myFuzzy::suite());
runner.run();
return 0;
}
谢谢你的回答!
std::ofstream ofs("tests.xml");
您没有指定应该在哪里创建test.xml文件。因此,默认情况下,它将在exe所在的同一文件夹中创建。
解决此问题的一种方法是指定在哪里创建/查找文件"C:test.xml"
,或者搜索项目文件夹,因为该文件可能是在调试bin中创建的。
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 使用std::multimap迭代器创建std::list
- 在全局变量中保存类的实例以重新创建类(创建"backup")
- 使用CMake创建QML插件
- 如何在c++中为模板函数实例创建快捷方式
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 试图在visual studio上用C++创建一个桌面应用程序
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 如何在C++20中创建模板别名的推导指南
- 尽管测试成功,CppUnit测试核心仍被丢弃.为什么
- 如何为模板化对象创建模板向量?VS正在投掷C3203
- 如何创建一个空的全局类并在启动时实例化它
- 无法创建抽象类的实例
- 链接到自行创建的dll失败
- CPPUNIT创建一个简单的测试
- 为什么两个"Start (Without) Debugging"(F5 和 Ctrl+F5)都不创建 CppUnit *.xml 报告文件?
- CPPUNIT:如何使用名称创建TestFixture的实例
- 在现有项目中创建CPPUnit测试需要哪些.cpp和.h文件