RobotTestingFramework 2.0.1
Robot Testing Framework
Loading...
Searching...
No Matches
LuaPluginLoader_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_LUAPLUGINLOADER_IMPL_H
23#define ROBOTTESTINGFRAMEWORK_LUAPLUGINLOADER_IMPL_H
24
26
27#include <lua.hpp>
28#include <lualib.h>
29#include <string>
30
31namespace robottestingframework {
32namespace plugin {
33
39{
40public:
45
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
90private:
91 bool getLocalFunction(const char* name);
93 std::string extractFileName(const std::string& path);
94
95 // lua accessible functions
96 static int setName(lua_State* L);
97 static int assertError(lua_State* L);
98 static int assertFail(lua_State* L);
99 static int testReport(lua_State* L);
100 static int testFail(lua_State* L);
101 static int testCheck(lua_State* L);
102 static int getTestEnvironment(lua_State* L);
103
104private:
105 lua_State* L;
106 std::string filename;
107 std::string error;
108#if LUA_VERSION_NUM > 501
109 static const struct luaL_Reg luaPluginLib[];
110#else
111 static const struct luaL_reg luaPluginLib[];
112#endif
113};
114
115} // namespace robottestingframework
116} // namespace plugin
117
118#endif // ROBOTTESTINGFRAMEWORK_LUAPLUGINLOADER_IMPL_H
The base class to implememnt a test case.
Definition TestCase.h:42
The LuaPluginLoaderImpl loads an test case plug-in and gives the direct access to the TestCase.
void close()
close Unloads the plugin and deletes any allocated memory.
std::string extractFileName(const std::string &path)
std::string getLastError()
getLastError gets the last error if any.
void tearDown() override
tearDown is called after the test run
TestCase * open(const std::string filename)
open Loads a test case plugin
std::string getFileName()
getFileName returns the loaded script file name
void setTestName(const std::string name)
setTestName set the test case name
~LuaPluginLoaderImpl() override
LuaPluginLoaderImpl destructor.
LuaPluginLoaderImpl()
LuaPluginLoaderImpl constructor.
void run() override
run is called by the TestCase class if setup is successfull;
bool setup(int argc, char **argv) override
setup is called before the test run.