|
23
|
| m_pGladiator · 技术社区 · 17 年前 |
|
|
1
3
要使用函数:
而不是WXentry。它不会调用应用程序的OnInit()或运行主循环。
你可以打电话
你需要使用
完成后。 |
|
2
12
我刚刚通过了2.8.10。神奇之处在于:
您可以创建一个wxapp实例,而不是使用上面的技术派生自己的类。 我不确定您希望如何在不进入主循环的情况下对应用程序进行单元测试,因为许多WXWidgets组件需要传递事件才能正常工作。通常的方法是在进入主循环之后运行单元测试。 |
|
|
3
4
|
|
|
4
1
看起来在wxapp::onrun()函数中进行测试可能有效。 下面是用cppunitlite2测试对话框标题的代码。
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/app.h" // use square braces for wx includes: I made quotes to overcome issue in HTML render
#include "wx/Frame.h"
#include "../CppUnitLite2\src/CppUnitLite2.h"
#include "../CppUnitLite2\src/TestResultStdErr.h"
#include "../theAppToBeTested/MyDialog.h"
TEST (MyFirstTest)
{
// The "Hello World" of the test system
int a = 102;
CHECK_EQUAL (102, a);
}
TEST (MySecondTest)
{
MyDialog dlg(NULL); // instantiate a class derived from wxDialog
CHECK_EQUAL ("HELLO", dlg.GetTitle()); // Expecting this to fail: title should be "MY DIALOG"
}
class MyApp: public wxApp
{
public:
virtual bool OnInit();
virtual int OnRun();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
return true;
}
int MyApp::OnRun()
{
fprintf(stderr, "====================== Running App Unit Tests =============================\n");
if ( !wxApp::OnInit() )
return false;
TestResultStdErr result;
TestRegistry::Instance().Run(result);
fprintf(stderr, "====================== Testing end: %ld errors =============================\n", result.FailureCount() );
return result.FailureCount();
}
|
|
5
-1
你可以扭转局面: 初始化并启动wxpython应用程序,包括主循环,然后从应用程序内部运行单元测试。我认为在完成所有init操作之后,有一个对主循环条目调用的函数。 |
|
|
6
-1
你试过了吗
从<wxwidgets'源目录\include\wx.h:
|
|
|
upsidedownone · 链接器处对“fff”的未定义引用 1 年前 |
|
|
gruszczy · gtest:预计_最终 2 年前 |
|
|
C0D3R · 如何重复模拟相同的函数并检查每个调用中的参数? 8 年前 |
|
|
Shereif SRF · 如何使用gtest到另一个测试的返回值 8 年前 |