Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryBlueBerryTestDriver.cpp
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 
18 
19 #include "internal/berryTestRegistry.h"
20 
21 #include "cppunit/TestRunner.h"
22 #include "cppunit/TestResult.h"
23 #include "cppunit/TestResultCollector.h"
24 
25 namespace berry
26 {
27 
29  const QList<ITestDescriptor::Pointer>& descriptors,
30  bool uitests,
31  const QString& testName,
32  bool wait)
33  : descriptors(descriptors)
34  , uitests(uitests)
35  , testName(testName)
36  , wait(wait)
37 {
38 
39 }
40 
42 {
43  CppUnit::TestRunner runner;
44 
45  unsigned int testCounter = 0;
46  foreach (const ITestDescriptor::Pointer& descr, descriptors)
47  {
48  if (descr->IsUITest() == uitests)
49  {
50  CppUnit::Test* test = descr->CreateTest();
51  runner.addTest(test);
52  ++testCounter;
53  }
54  }
55 
56  if (testCounter == 0)
57  {
58  std::cout << "No " << (uitests ? "UI " : "") << "tests registered."
59  << std::endl;
60  return 0;
61  }
62 
63  /*
64  std::vector<std::string> args;
65  args.push_back("BlueBerryTestDriver");
66  if (testName.empty())
67  args.push_back("-all");
68  else
69  args.push_back(testName);
70  if (wait)
71  args.push_back("-wait");
72 
73  return runner.run(args) ? 0 : 1;
74  */
75 
76  CppUnit::TestResult controller;
77 
78  CppUnit::TestResultCollector result;
79  controller.addListener(&result);
80 
81  runner.run(controller);
82  return result.wasSuccessful() ? 0 : 1;
83 }
84 
85 int BlueBerryTestDriver::Run(const QString& pluginId, bool uitests)
86 {
87  TestRegistry testRegistry;
88  const QList<ITestDescriptor::Pointer>& tests = testRegistry.GetTestsForId(
89  pluginId);
90 
91  BlueBerryTestDriver driver(tests, uitests);
92  return driver.Run();
93 }
94 
95 }
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
Definition: testcase.h:32
QList< ITestDescriptor::Pointer > descriptors
BlueBerryTestDriver(const QList< ITestDescriptor::Pointer > &descriptors, bool uitests=false, const QString &testName="", bool wait=false)