RobotTestingFramework  2.0.1
Robot Testing Framework
PythonPluginLoader_impl.h
Go to the documentation of this file.
1 /*
2  * Robot Testing Framework
3  *
4  * Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 
22 #ifndef ROBOTTESTINGFRAMEWORK_PYTHONPLUGINLOADER_IMPL_H
23 #define ROBOTTESTINGFRAMEWORK_PYTHONPLUGINLOADER_IMPL_H
24 
26 
27 #include <Python.h>
28 #include <string>
29 
30 namespace robottestingframework {
31 namespace plugin {
32 
38 {
39 public:
44 
49 
56  TestCase* open(const std::string filename);
57 
62  void close();
63 
68  std::string getLastError();
69 
74  std::string getFileName();
75 
80  void setTestName(const std::string name);
81 
82  bool setup(int argc, char** argv) override;
83 
84  void tearDown() override;
85 
86  void run() override;
87 
88 public:
89  static PyObject* setName(PyObject* self, PyObject* args);
90  static PyObject* assertError(PyObject* self, PyObject* args);
91  static PyObject* assertFail(PyObject* self, PyObject* args);
92  static PyObject* testReport(PyObject* self, PyObject* args);
93  static PyObject* testCheck(PyObject* self, PyObject* args);
94 
95 private:
96  std::string getPythonErrorString();
97 
98 private:
99  std::string filename;
100  std::string error;
101 
102  PyObject* pyName;
103  PyObject* pyModule;
104  PyObject* pyDict;
105  PyObject* pyClass;
106  PyObject* pyInstance;
109  static PyMethodDef testPythonMethods[];
110 };
111 
112 } // namespace robottestingframework
113 } // namespace plugin
114 
115 #endif // ROBOTTESTINGFRAMEWORK_PYTHONPLUGINLOADER_IMPL_H
The base class to implememnt a test case.
Definition: TestCase.h:42
The PythonPluginLoaderImpl loads a Pthyon test case plug-in and gives the direct access to the TestCa...
void setTestName(const std::string name)
setTestName set the test case name
static PyObject * setName(PyObject *self, PyObject *args)
TestCase * open(const std::string filename)
open Loads a test case plugin
bool setup(int argc, char **argv) override
setup is called before the test run.
static PyObject * testReport(PyObject *self, PyObject *args)
void run() override
run is called by the TestCase class if setup is successfull;
void tearDown() override
tearDown is called after the test run
static PyObject * assertError(PyObject *self, PyObject *args)
void close()
close Unloads the plugin and deletes any allocated memory.
~PythonPluginLoaderImpl() override
PythonPluginLoaderImpl destructor.
PythonPluginLoaderImpl()
PythonPluginLoaderImpl constructor.
static PyObject * testCheck(PyObject *self, PyObject *args)
static PyObject * assertFail(PyObject *self, PyObject *args)
std::string getFileName()
getFileName returns the loaded script file name
std::string getLastError()
getLastError gets the last error if any.