Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate Junit output report using Behave Python

I'm using Behave on Python to test a web application. My test suite run properly, but I'm not able to generate junit report.

Here is my behave.ini file :

    [behave]
junit=true
format=pretty

I only run behave using this command :behave

After run, the test result is print in the console, but no report is generated.

1 feature passed, 3 failed, 0 skipped
60 scenarios passed, 5 failed, 0 skipped
395 steps passed, 5 failed, 5 skipped, 0 undefined
Took 10m17.149s

What can I do ?

like image 687
julien88 Avatar asked Dec 08 '15 09:12

julien88


People also ask

Can we use JUnit with Python?

The Python unit testing framework, dubbed 'PyUnit' by convention, is a Python language version of JUnit, by smart cookies Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent's Smalltalk testing framework. Each is the de facto standard unit testing framework for its respective language.

How do I run an act file?

For Behave installation, we should have pip – the package installer for the Python language installed in our system. The pip is installed by default, if the Python version is greater than 2(upto 2.7. 9). We can also use the easy_install for the Behave installation.


1 Answers

Make sure you don't change the working directory in your steps definition (or, at the end of the test change it back to what it was before). I was observing the same problem, and it turned out that the reports directory was created in the directory I changed into while executing one of the steps.

What may help, if you don't want to care about the working directory, is setting the --junit-directory option. This should help behave to figure out where to store the report, regardless of the working directory at the end of the test (I have not tested that though)

like image 66
botchniaque Avatar answered Sep 19 '22 20:09

botchniaque