Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Srinivasan Ramesh
sonata
Commits
cf6b8e44
Commit
cf6b8e44
authored
Mar 31, 2020
by
Matthieu Dorier
Browse files
started adding cppunit tests
parent
8c14bbdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/CMakeLists.txt
View file @
cf6b8e44
add_executable
(
mytest test.cpp
)
target_include_directories
(
mytest PUBLIC $<INSTALL_INTERFACE:include>
)
target_include_directories
(
mytest BEFORE PUBLIC
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include>
)
target_link_libraries
(
mytest sonata-admin sonata-server sonata-client
)
include_directories
(
../include
)
add_library
(
sonata-test Main.cpp
)
target_link_libraries
(
sonata-test
${
CPPUNIT_LIBRARIES
}
sonata-server sonata-admin sonata-client
)
test/Main.cpp
0 → 100644
View file @
cf6b8e44
#include <fstream>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <sonata/Client.hpp>
#include <sonata/Admin.hpp>
#include <sonata/Provider.hpp>
namespace
tl
=
thallium
;
tl
::
engine
*
engine
=
nullptr
;
int
main
(
int
argc
,
char
**
argv
)
{
// Get the top level suite from the registry
CppUnit
::
Test
*
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
().
makeTest
();
// Adds the test to the list of test to run
CppUnit
::
TextUi
::
TestRunner
runner
;
runner
.
addTest
(
suite
);
std
::
ofstream
xmlOutFile
;
if
(
argc
>=
2
)
{
const
char
*
xmlOutFileName
=
argv
[
1
];
xmlOutFile
.
open
(
xmlOutFileName
);
// Change the default outputter to output XML results into a file
runner
.
setOutputter
(
new
CppUnit
::
XmlOutputter
(
&
runner
.
result
(),
xmlOutFile
));
}
else
{
// Change the default outputter to output XML results into stderr
runner
.
setOutputter
(
new
CppUnit
::
XmlOutputter
(
&
runner
.
result
(),
std
::
cerr
));
}
// Initialize the thallium server
tl
::
engine
theEngine
(
"na+sm"
,
THALLIUM_SERVER_MODE
);
engine
=
&
theEngine
;
// Initialize the Sonata provider
sonata
::
Provider
provider
(
theEngine
);
// Run the tests.
bool
wasSucessful
=
runner
.
run
();
// Finalize the engine
theEngine
.
finalize
();
if
(
argc
>=
2
)
xmlOutFile
.
close
();
// Return error code 1 if the one of test failed.
return
wasSucessful
?
0
:
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment