Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryUITestCaller.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef BERRYUITESTCALLER_H_
19 #define BERRYUITESTCALLER_H_
20 
21 #include <cppunit/TestCase.h>
22 #include <cppunit/Guards.h>
23 
24 #include <memory>
25 
26 namespace berry {
27 
28 template <class Fixture>
29 class UITestCaller: public CppUnit::TestCase
30 {
31  REFERENCEOBJECT (UITestCaller)
32 
33  typedef void (Fixture::*TestMethod)();
34 
35 public:
36  UITestCaller(const std::string& name, TestMethod test):
37  CppUnit::TestCase(name),
38  _test(test),
39  _fixture(new Fixture(name))
40  {
41  }
42 
43 protected:
44  void runTest()
45  {
46  (_fixture.get()->*_test)();
47  }
48 
49  void setUp()
50  {
51  _fixture.get()->DoSetUp();
52  }
53 
54  void tearDown()
55  {
56  _fixture.get()->DoTearDown();
57  }
58 
59 private:
60  TestMethod _test;
61  std::unique_ptr<Fixture> _fixture;
62 };
63 
64 
65 } // namespace berry
66 
67 
68 #define CppUnit_addUITest(suite, cls, mth) \
69  suite->addTest(new berry::UITestCaller<cls>(#mth, &cls::mth))
70 
71 #endif /* BERRYUITESTCALLER_H_ */
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
Definition: testcase.h:32
UITestCaller(const std::string &name, TestMethod test)