当前位置: 首页>>代码示例>>C++>>正文


C++ TestSuite::getTestCaseCount方法代码示例

本文整理汇总了C++中TestSuite::getTestCaseCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TestSuite::getTestCaseCount方法的具体用法?C++ TestSuite::getTestCaseCount怎么用?C++ TestSuite::getTestCaseCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestSuite的用法示例。


在下文中一共展示了TestSuite::getTestCaseCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

	threadproc_ret _callconv TestRunner::run(void* pUserData)
	{
		const ThreadInfo* pInfo = static_cast<const ThreadInfo*>(pUserData);
		assert(pInfo);
		assert(pInfo->pRunner);

		TestRunner* pRunner = pInfo->pRunner;
		assert(pRunner->m_testSuiteList);
		assert(pRunner->m_nbTestSuites);

		RTErrorProtector errorProtector(pRunner->m_pTestListener, pInfo->threadIdx);

		TestEvent event;
		stats::CodeTimer suiteTimer;
		stats::CodeTimer caseTimer;
		for (;;)
		{
			bool bStopRequested = pRunner->m_bStopRequested.load(std::memory_order_relaxed);
			if (bStopRequested)
				break;

#ifndef EASYTEST_NO_THREADS
			size_t idx = pRunner->m_nextTestSuiteIdx.fetch_add(1, std::memory_order_relaxed);
#else //EASYTEST_NO_THREADS is defined
			size_t idx = pRunner->m_nextTestSuiteIdx++;
#endif //!EASYTEST_NO_THREADS

			if (idx >= pRunner->m_nbTestSuites)
				break;

			suiteTimer.start();

			const TestSuiteRegistrar* pRegistrar = pRunner->m_testSuiteList[idx];
			bool bTestSuiteSuccess = false;
			TestSuite* pTestSuite = errorProtector.createProtectedTestSuite(pRegistrar);
			if (pTestSuite)
			{
				assert(pRegistrar);
				bTestSuiteSuccess = true;

				const size_t nbTotalCases = pTestSuite->getTestCaseCount();
				size_t nbSuccessCases = 0;
				size_t nbFailedCases = 0;

				if (pRunner->m_pTestListener)
				{
					event.type = TestEventType::TESTSUITE_START;
					event.testSuiteStart.workerThreadIdx = pInfo->threadIdx;
					event.testSuiteStart.testSuiteName = pRegistrar->getTestSuiteName();
					event.testSuiteStart.nbTotalCases = nbTotalCases;
					pRunner->m_pTestListener->onEvent(event);
				}

				const TestCaseRegistrar** caseRegListBegin = pTestSuite->getTestCaseList();
				const TestCaseRegistrar** caseRegListEnd = caseRegListBegin + nbTotalCases;
				for (const TestCaseRegistrar** ppCaseReg = caseRegListBegin; ppCaseReg < caseRegListEnd; ++ppCaseReg)
				{
					assert(*ppCaseReg);

					bStopRequested = pRunner->m_bStopRequested.load(std::memory_order_relaxed);
					if (bStopRequested)
					{
						bTestSuiteSuccess = false;
						break;
					}

					caseTimer.start();

					if (pRunner->m_pTestListener)
					{
						event.type = TestEventType::TESTCASE_START;
						event.testCaseStart.testCaseName = (*ppCaseReg)->getTestName();
						pRunner->m_pTestListener->onEvent(event);
					}

					if (errorProtector.executeProtectedTestCase(*ppCaseReg))
					{
						event.testCaseFinish.bSuccess = true;
						nbSuccessCases++;
					}
					else
					{
						event.testCaseFinish.bSuccess = false;
						nbFailedCases++;
						bTestSuiteSuccess = false;
					}

					caseTimer.stop();

					if (pRunner->m_pTestListener)
					{
						event.type = TestEventType::TESTCASE_FINISH;
						event.testCaseFinish.pTimer = &caseTimer;
						pRunner->m_pTestListener->onEvent(event);
					}
				}

				errorProtector.deleteProtectedTestSuite();

				suiteTimer.stop();
//.........这里部分代码省略.........
开发者ID:neodesys,项目名称:EasyTest,代码行数:101,代码来源:TestRunner.cpp


注:本文中的TestSuite::getTestCaseCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。