void testList();
void testField();
void testAddButton();
void testDeleteButton();
private:
MovieListWindow* m_pWindow;
};
其中,MovieListWindow是一个窗口类。我们来看看其中的一个测试,请看代码中的注释。
void TestWidgets::testAddButton()
{
//得到btn指针
CButton* pAddButton = m_pWindow->GetAddButton();
//检查是否生成btn
CPPUNIT_ASSERT(pAddButton->m_hWnd);
//检查btn是否可见
CPPUNIT_ASSERT_EQUAL(TRUE, ::IsWindowVisible(pAddButton->m_hWnd));
CString strText;
pAddButton->GetWindowText(strText);
CString strExpect = "Add";
//检查btn的Label文字是否正确
CPPUNIT_ASSERT_EQUAL(strExpect, strText);软件测试
}
编译测试代码,编译器会给我们一些出错信息。这要求我们必须马上编写产品代码以让编译通过。首先第一个要实现的产品代码就是MovieListWindow窗口类。
文章来源于领测软件测试网 https://www.ltesting.net/