13#ifndef ARCANE_CORE_UNITTESTADAPTER_H
14#define ARCANE_CORE_UNITTESTADAPTER_H
18#include "arcane/core/IUnitTest.h"
19#include "arcane/core/ArcaneException.h"
21#include "arcane/core/XmlNode.h"
37class UnitTestServiceAdapter
47 explicit UnitTestServiceAdapter(T* service)
57 void addTestFunction(
FuncPtr f, String name, String method_name)
76 report.
setAttrValue(
"name", m_service->serviceInfo()->localName());
78 XmlNode xunittest = report.createAndAppendElement(
"unit-test");
81 xunittest.
setAttrValue(
"method-name", func_info.m_method_name);
84 (m_service->*func_info.m_test_func)();
88 m_service->info() <<
"[OK ] " << func_info.m_name;
92 XmlNode xexception = xunittest.createAndAppendElement(
"exception");
97 m_service->info() <<
"[FAILURE] " << func_info.m_name <<
" (line " << e.
line() <<
" in " << e.
where() <<
")";
98 m_service->info() <<
" " << e.
message();
117 : m_test_func(test_func)
119 , m_method_name(method_name)
Exception in an assertion.
const String & where() const
Location of the exception.
const char * file() const
File of the exception.
const String & message() const
Exception message.
int line() const
Line of the exception.
Base class for assertions in unit tests.
Interface of a unit test service providing a test report in the form of an XML node.
Unicode character string.
1D data vector with value semantics (STL style).
void initializeTest() override
Implementation of the IUnitTest interface.
bool executeTest(XmlNode &report) override
Implementation of the IUnitTest interface.
void finalizeTest() override
Implementation of the IUnitTest interface.
UniqueArray< TestFuncInfo > m_test_functions
Associated service.
FuncPtr m_set_up_function
Pointer to the initialization method of each test.
FuncPtr m_tear_down_function
Pointer to the teardown method of each test.
FuncPtr m_class_tear_down_function
Pointer to the class teardown method.
FuncPtr m_class_set_up_function
Pointer to the class initialization method.
void(T::* FuncPtr)()
Type of the pointer to the test methods.
void setAttrValue(const String &name, const String &value)
Sets the attribute name to the value value.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --