RobotTestingFramework  2.0.1
Robot Testing Framework
RubyPluginLoader_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_RUBYPLUGINLOADER_IMPL_H
23 #define ROBOTTESTINGFRAMEWORK_RUBYPLUGINLOADER_IMPL_H
24 
26 
27 #include <ruby.h>
28 #include <string>
29 
30 namespace robottestingframework {
31 namespace plugin {
32 
38 {
39 
40 public:
45 
49  ~RubyPluginLoaderImpl() override;
50 
57  TestCase* open(const std::string filename);
58 
63  void close();
64 
69  std::string getLastError();
70 
75  std::string getFileName();
76 
81  void setTestName(const std::string name);
82 
83  bool setup(int argc, char** argv) override;
84 
85  void tearDown() override;
86 
87  void run() override;
88 
89 
90 private:
91  std::string extractFileName(const std::string& path);
92 
94  static std::string getRubyErrorMessage();
95  static std::string getRubyBackTrace();
96 
97  static VALUE wrapSetup(VALUE args);
98  static VALUE protectedSetup(VALUE testcase, ID id, VALUE param, RubyPluginLoaderImpl* impl);
99  static VALUE wrapRun(VALUE args);
100  static VALUE protectedRun(VALUE testcase, ID id, RubyPluginLoaderImpl* impl);
101  static VALUE wrapTearDown(VALUE args);
102  static VALUE protectedTearDown(VALUE testcase, ID id, RubyPluginLoaderImpl* impl);
103 
104  static VALUE setName(VALUE self, VALUE obj);
105  static VALUE assertError(VALUE self, VALUE obj);
106  static VALUE assertFail(VALUE self, VALUE obj);
107  static VALUE testReport(VALUE self, VALUE obj);
108  static VALUE testCheck(VALUE self, VALUE cond, VALUE message);
109 
110 private:
111  std::string filename;
112  std::string error;
113  VALUE testcase;
115 };
116 
117 } // namespace plugin
118 } // namespace robottestingframework
119 
120 #endif // ROBOTTESTINGFRAMEWORK_RUBYPLUGINLOADER_IMPL_H
std::string getLastError()
getLastError gets the last error if any.
static VALUE protectedRun(VALUE testcase, ID id, RubyPluginLoaderImpl *impl)
bool setup(int argc, char **argv) override
setup is called before the test run.
~RubyPluginLoaderImpl() override
RubyPluginLoaderImpl destructor.
static VALUE testReport(VALUE self, VALUE obj)
void run() override
run is called by the TestCase class if setup is successfull;
TestCase * open(const std::string filename)
open Loads a test case plugin
The base class to implememnt a test case.
Definition: TestCase.h:41
std::string extractFileName(const std::string &path)
void tearDown() override
tearDown is called after the test run
void setTestName(const std::string name)
setTestName set the test case name
static VALUE protectedTearDown(VALUE testcase, ID id, RubyPluginLoaderImpl *impl)
void close()
close Unloads the plugin and deletes any allocated memory.
static VALUE setName(VALUE self, VALUE obj)
static VALUE assertError(VALUE self, VALUE obj)
static VALUE testCheck(VALUE self, VALUE cond, VALUE message)
The RubyPluginLoaderImpl loads a ruby test case plug-in and gives the direct access to the TestCase...
static VALUE protectedSetup(VALUE testcase, ID id, VALUE param, RubyPluginLoaderImpl *impl)
std::string getFileName()
getFileName returns the loaded script file name
static VALUE assertFail(VALUE self, VALUE obj)
static RubyPluginLoaderImpl * getImpFromRuby()
RubyPluginLoaderImpl()
RubyPluginLoaderImpl constructor.