经过长时间的互联网搜索,我想问您以下问题。
我们使用 Jenkins 来构建和单元测试用 C++ 编写的模拟代码。
这非常有效。在研究了 Fitnesse 和 RobotFramework 之后,我仍然无法运行以下测试问题。
我的程序是一个命令行程序,它读取一些输入文件并计算一些输出数据。 (例如 simcode.exe -j input##.inp --> output.dat)
我正在寻找一种可以通过 Web 界面创建测试套件的方法。这意味着我为每个测试用例提供一个输入文件和一些参考输出数据,然后在成功构建 Jenkins 后执行测试套件。根据输出数据和参考输出数据之间的差异结果,应创建一个可提供给 Jenkins 的 xml 文件。此 xml 文件应包含有关所有测试用例结果的信息(例如成功或失败)。
xml文件的信息应该会再次显示在Jenkins中。
我正在寻找一种不需要将任何库编译到我的程序中的方法。
我将非常感谢任何解释如何使用 RobotFramework 实现这一目标的提示。 (这可能吗?)
提前致谢!
after a long Internet search I would like to ask you the following question.
We are using Jenkins for building and unit testing of a simulation code which is written in C++.
This works very well. After looking into fitnesse and robotframework I am still not able to run the following test problems.
My program is a command line program which reads some input file and computes some output data. (e.g. simcode.exe -j input##.inp --> output.dat)
I am looking for a way that I can create a test suite via a web interface. Meaning I provide for each test case a input file and some reference output data and the test suite is than executed after a successful build out of Jenkins. Based on the results of the difference between output data and reference output data, a xml file should be created which can be given to Jenkins. This xml file should hold information about all the test case results (e.g. successful or not).
The information of the xml file should be displayed in Jenkins again.
I looking for an approach where I do not need to compile any library to my program.
I would be very thankful for any hint which explains how to achieve that with the RobotFramework. (Is it even possible ?)
Thanks in advance!
发布评论
评论(2)
Robot Framework 是一个测试自动化工具...您可以用它做很多不同的事情...
我不太明白您通过 Web 界面使用测试套件的意思...但总的来说,您描述的功能似乎是可以使用 RobotFramework 完成...
简而言之,
您可以创建一个可以包含许多测试用例的测试套件,例如您可以拥有一个或每个要检查的输入文件!
操作系统内置库有关键字 Run,您可以使用它,或者如果您远程运行命令,您可以使用可选 SSHLibrary
对于每个测试用例您可以创建一个运行该命令的步骤,以及另一个根据您的预期验证输出文件的步骤。如果它们匹配,则测试用例被标记为“通过”,否则被标记为“失败”...
RobotFramework 可以为您运行的每个测试套件生成 html 格式的日志和报告文件。
Jenkins 和 Hudson 有一个 RobotFramework 插件,您可以使用它以非常好的方式显示这些输出文件!
即有多少测试用例通过/失败
Robot Framework is a test automation tool... you can do many different things with that...
I don't really understand what you mean with the test suite via a web interface... but in general the functionality you describe seems that can be done with RobotFramework...
In Brief
You can create a Test Suite that can have many Test Cases for example you could have onef or every input file you want to check!
The OperatingSystem Build In Library has the Keyword Run, that you can probably use or if you are running the commands remotely you can use the Execute Command from the optional SSHLibrary
For Every Test Case you could create a step that runs the command and another one that verifies the output file against what you expected. If they match the Test Case is marked as Pass, else it is marked as Fail...
RobotFramework can produce for every Test Suite that you run a log and report file that are in html format.
Jenkins and Hudson have a plugin for RobotFramework that you can use to display these output files in a very nice way!
i.e. How many Test Cases have Passed/Failed
你想要的似乎是灵丹妙药。
这是可行的,你不需要编译任何东西,但你仍然需要围绕机器人框架编写一些逻辑。
所以所有繁重的工作已经完成。
调用 CLI - 使用操作系统
<前><代码>*** 设置 ***
图书馆操作系统
*** 测试用例 ***
基础测试
运行命令 simcode.exe -j input01.inp
*** 关键词 ***
运行命令
[参数] ${命令}
${rc} ${output} = 运行并返回 RC 和输出 ${command}
记录${输出}
应等于整数 ${rc} 0
不应包含 ${output} 失败
如果您想要一种灵活的方法来输入内容
<前><代码>*** 设置 ***
图书馆操作系统
*** 测试用例 ***
组合
[模板] 基本测试
输入01.inp
输入02.inp
输入03.inp
*** 关键词 ***
基础测试
[参数] ${输入}
运行命令 simcode.exe -j ${input}
运行命令
[参数] ${命令}
${rc} ${output} = 运行并返回 RC 和输出 ${command}
记录${输出}
应等于整数 ${rc} 0
不应包含 ${output} 失败
接下来,我们需要比较两个文件的内容......
假设您将文件移动到一个方便的位置,您可以自己编写一个关键字来比较内容
<前><代码>*** 设置 ***
图书馆操作系统
*** 测试用例 ***
组合
[模板] 基本测试
../资源/input01.inp ../资源/expectedoutput01.out
../资源/input02.inp ../资源/expectedoutput02.out
../资源/input03.inp ../资源/expectedoutput03.out
*** 关键词 ***
基础测试
[参数] ${输入} ${expected_output}
运行命令 simcode.exe -j ${input}
日志文件输出.data
比较文件 ${expected_output} output.data
让我们假设内容是 ini 格式的参数列表。
例如,假设您计算输入文件中存在的数字的平方根,
我们如何存储预期数据?
假设我们有一个名为expected.dat的文件
并且我们有一个output.data
然后我们需要自己编写一个文件比较器。
如果您确信文件应该相同,则可以使用 diff 和 OperatingSystem 库,或者可以编写一个简单的比较器,例如:
4 和 5。运行后,您可以使用发布工件和发布机器人结果插件来传递詹金斯的格式良好的输出。
瞧!
PS:代码可能无法运行 - 我在一个简单的编辑器中自由编写了它,没有语法突出显示,并且我没有测试它。
What you want seems like a silver bullet.
It is feasible, you don't need to compile a thing, but you still need to write some logic around robot framework.
So all the heavy lifting is already done.
Calling CLI - use OperatingSystem
If you want a flexible approach to inputting stuff
Next, we need to compare the content of two files...
Assuming that you moved your files around to a convenient location you can write yourself a keyword to compare the content
Let's assume that the content is a list of parameters, in the ini format.
For example let's assume that you calculate the square root for the numbers present in the input file
How do we store the expected data?
Let's assume we have a file called expected.dat
And we have an output.data
Then we need to write ourselves a file comparator.
Either you go with diff and the OperatingSystem library, if you are confident that the files should be identical or you can write a simple comparator like:
4 and 5. After you run, you use the publish artefact and publish robot results plugins to pass the nicely formatted output to Jenkins.
Voila!
PS: The code might not run - I wrote it freestyle in a simple editor without syntax highlighting and I did not tested it.