dutchiexl / behathtmlformatterplugin Goto Github PK
View Code? Open in Web Editor NEWThis is a behat plugin to generate HTML reports
License: MIT License
This is a behat plugin to generate HTML reports
License: MIT License
I was able to get this really great project here running.
But I do not really need it on a hard drive. I want to embed the genereated stuff into the E-Mail that is send when the Test are crashing.
So is the currently possible. Or is this project only for watching on a local machine, just to have a nice view on all the different tests?
But all the other things work great! I just need it in the E-Mail.
I will like use your html export in different language.
Is it posible enable doing translate version?
I mean for example:
1 features ( 1 fail )
9 scenarios ( 8 success 1 fail )
77 steps ( 76 success 1 fail )
[+] all [-] all
Suite :
Feature:
Scenario:
Scenario Outline:
Feature has failed Scenarios passed : 88.89%, Scenarios failed : 11.11%
1 features failed of 1 features
1 scenarios failed of 9 scenarios
1 steps failed of 77
Failed: 1
Passed: 76
I add this to my behat.yml :
formatters:
html:
output_path: %paths.base%/
extensions:
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig
file_name: Index
print_args: true
print_outp: true
loop_break: true
And behat show error : [Behat\Testwork\Output\Exception\FormatterNotFoundException]
html formatter is not found or has not been properly registered. Registered formatters: junit, progress, pretty.
Can anybody help me?
This plugin only works for single run or session of the test. When I tried to run in parallel, the report is not consolidated.
Behat2Renderer.php:333
if (!empty($step->getException())) {
Hi, I thought that you might want to use this https://styleci.io/
It may make your life easier with coding standard.
Btw which one do you follow ?
Hi,
The plugin is great and Im using it regularly for generating reports. I have only one question.
Is it possible to avoid the overwriting of the base file ? My goal is to have different html file for every test or at least for every test suite. Can you give me some directions how to approach this ?
Regards
hi,
I hope it's a good place for that, but reference on packagist is not updated. Now it says "reference: c9a0be3" which is more than 30 commits ago. So now to get the latest version I need to write in composer.json "emuse/behat-html-formatter": "dev-master#3e372584755b81bfcd6e0611eb644ccb7cda4efe". Is there a chance to update reference on packagist?
Cheers
When a large amount of features/scenarios/steps are present in a report, the rendering of the page starts showing strange behaviour.
It looks as though the page is rendering, but then a lot of the information is lost, and everything collapses in a weird order.
I've attached a couple of example screenshots.
Hi,
I had configured the emuse within .yml file as below:
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
print_outp: true
file_name: index
print_args: true
loop_break: true
I used both format because whenever there is a fatal error or something Twig does not give any result. Behat2 gives result till where it was executed
Issue:
When result was generated in html format it had both format within but when TWIG results were it did not show any tests.
Can anybody please let me know how to resolve this?
I'm using this plugin
https://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin
And forces me to specify a index file.
Before it was report.html
Now it has a date and I cannot view the html.
I would like a way to make the name of this file predictable.
Hello,
In your css, could you change the url of google fonts to be agnostic:
Change http://fonts.google... to //fonts.google...
Cf. http://stackoverflow.com/questions/18026809/google-web-fonts-on-https-pages-on-chrome
Thank you.
Behat has a flag --out
or -o
to specify where report output should be saved:
--out (-o) Write format output to a file/directory instead of
STDOUT (output_path). You can also provide different
outputs to multiple formats. (multiple values allowed)
It took me a little while to find the current output path (hard-coded to {$PROJECTROOT}/vendor/emuse/behat-html-formatter/reports/test_report.html
). It is probably worth adding a note to the readme file to explain this until the extension can support user-defined paths.
Hi there
I've noticed that we already have implementation of making screenshot on failure
But it seems not working pretty well or easy
Is it possible to have not only screenshot for each feature but rather each steps that failed?
So, for ex. a feature has a few scenarios some of them are success and some failed and we'd able to view what exactly was on the page when steps couldn't pass.
btw. thanks guys for this very useful feature
Hello,
When I'm using some basic configuration:
default:
extensions:
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
file_name: Index
print_args: true
print_outp: true
loop_break: true
formatters:
html:
output_path: %paths.base%/build/html/behat
The console output disappears, but html generation works fine!
Did I miss something ?
Hi, I installed plugin as instructed on the readme document. and I can see it's installed in the directory: vendor/emuse/behat-html-formatter/
And here is my yml file:
default:
extensions:
Behat\MinkExtension\ServiceContainer\MinkExtension:
show_cmd: /usr/bin/google-chrome %s
show_auto: true
selenium2:
browser: chrome
wd_host: http://127.0.0.1:4444/wd/hub
suites:
cock_pit:
paths: [ %paths.base%/features/cock_pit]
contexts: [ Ubiflow\CockPit\FeatureContext ]
formatters:
html:
output_path: %paths.base%/results/html
extensions:
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
file_name: Index
print_args: true
print_outp: true
loop_break: true
When I execute the test, I got this error:
[Behat\Testwork\Output\Exception\FormatterNotFoundException]
`html` formatter is not found or has not been properly registered.
It seems behat is unable to link the formatter with the plugin. Any idea where I did wrong?
Thanks!
Hey there,
the generated report doesn't seems to be rendered with the correct path to the ChartJs (and the style.css as well).
The path where it looks for the js and css is: %path_to_generated_report%/assets/
Is it happening with anyone else or is just me doing something wrong on the configuration?
Now that more and more people are starting to use this extension, it might be useful to add some information on the README file about installing this extension. I know, this seems to be straight forward but I'd expect a lot of issues coming in with questions on how to install this extension!
Another suggestion might be using Read the docs. But that might be a bit overkill yet.
Hi, I am using this plugin, it really helped me a lot!
In the title are two additional features that I made to my needs, commited here: lucaswong2000@7058aa4
If interested, I'd be glad to creat a pull request to merge my changes. ;-)
Thanks again for this awsome plugin!
As I set my language to "de"
default:
translation:
locale: de
extensions:
Behat\MinkExtension:
sessions:
default:
goutte: ~
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig
formatters:
html:
output_path:
%paths.base%/var/behat
autoload:
'': %paths.base%/tests/features/bootstrap
suites:
wordpress:
paths: [ %paths.base%/tests/features ]
contexts: [ WordPressContext ]
the behat output with other formatter is German (de). But the words "Feature", "Scenario" are still english in the HTML-Output. As there is still no HTML-Ouput for Behat3 and yours look very good, please fix this :)
Cheers!
Hi !
I am using emuse and I like the way it reports. Just had following query related to emuse
1.During execution in any case if a fatal error /session kill occurs, whole test execution is stopped. During this condition If I try to view the report it will be blank. Is there any config that I could see the report even on failure conditions
2. Is there any config that can be made so that report can be seen while execution?
Please let me know if we can.
Thanks in advance!
-Mahesh
It would be good if there is a separator or some kind of markup between several "sub"scenarios in an scenario outline.
Right now it looks like they are all one big scenario with repeated Given - When - Then steps.
When using Tables (TableNode) in a test the values are not displayed in the reports.
Example
Scenario: There should be 6 services and each streams value should be integers
Given .... Tracker Page
When I select Time Period "Lifetime"
Then I can only select two services at any given time
And services should be
| service |
| fdgsfgsdfg |
| sdfgsdfgdfg |
| sfdgsdfgsd |
And region should be
| region |
| Americas |
| Europe |
And each streams value should be an integer number uk formatted
Can this be fixed?
Hi,
I get the following error when I launch my tests suite :
PHP Fatal error: Call to undefined method Behat\Gherkin\Node\StepNode::getKeyword()
Don't know what to do ?
Btw, this extension is a great idea
Hi guys,
Recently I get an error when I run behat tests. Message is
PHP Fatal error: Class 'emuse\BehatHTMLFormatter\Renderer\behat2Renderer' not found in /home/grzegorzdobiecki/projekty/nse-learning-services-client/vendors_behat/emuse/behat-html-formatter/src/Renderer/BaseRenderer.php on line 44
I found class Behat2Renderer (capital B) in vendors.
HEAD is at
commit f3bcf07
Author: Neal Vanmeert [email protected]
Date: Fri Mar 20 14:20:21 2015 +0100
But I notice that is worked when HEAD was at commit 801cc56
Hi!
I have question about getting scenario name in report
Step by step explenation my case
I set scenario title in my FeatureContext
public function setUpTestEnvironment($scope)
{
$this->currentScenarioTitle = $scope->getScenario()->getTitle;
}
When i getTitle durint test execution i get something like this:
| some| test| parameter| parameter1|
This string is from my Scenario Example table
Scenario Outline: Open page anf validate something
Given I am on page
When New page is displayed
Then I should see
Examples:
| header1| header2| header3| header4|
| some| test| parameter| parameter1|
4.After test execution when i try get scenario name using getName in \vendor\emuse\behat-html-formatter\src\Classes\Scenario.php
i get only Scenario Title, in my case it is "Open page anf validate something"
but i need title from Example table like this "| some| test| parameter| parameter1|"
Could you please explain how to get it?
Hi guys,
Behat 3.0.15
Php unit 4.8.3
Tests executes from bamboo unix on slave Windows 7.
After nightly build I have report with not all feature in it.
In report at the bottom I do not see thouse circlus like you have on screen shots but only the text:
3 features failed of 14 features. 4 scenarios failed of 36 scenarios,35 steps failed of 1479 and then below description for thouse 6 features I see in the body.If you need I can send tar file. Also attached the screenshot and my yml file below.
Clicks on buttons all passed failed do nothing.
default:
autoload:
'': %paths.base%/features/bootstrap
suites:
test:
paths:
- %paths.base%/features
contexts:
- HorseProfileContext
filters:
tags: @fakeData,@realData,@brokenTest,@disabledTest
formatters:
html:
output_path: %paths.base%/build/html/behat
extensions:
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Twig,Behat2
file_name: Index
print_args: true
print_outp: true
loop_break: true
Aditional remark: When I run one feature on my local pc(php storm added reporter through composer in storm) report is ok.
I litteraly copied/pasted the settings from the README file. This results in an error;
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized option "print_table" under "testwork.emusehtml"
When a scenario is used in multiple suites (behat 3) the screenshot is overwritten by a new screenshot.
Solution: Use suite names in the screenshot name.
Example:
results/html/assets/screenshots/{{suite_name}}/{{feature_name}}/{{scenario_name}}.png
The error above occurs because the method call inside a empty function
I using php 5.4
PHP Fatal error: Can't use method return value in write context in /home/dbseller/.composer/vendor/emuse/behat-html-formatter/src/Renderer/Behat2Renderer.php on line 333
When opening the detail view of a feature, the failed steps should be able to display the exception in an intuitive way.
The steps allready have the exception in their class when rendered, but are not yet rendered in the HTML.
In throwing an exception within my Behat Step definition, I correctly fail a given behat test. However, before the command returns, I get the following:
Recoverable fatal error: Argument 1 passed to emuse\BehatHTMLFormatter\Formatter\BehatHTMLFormatter::onAfterSuiteTested() must be an instance of Behat\Testwork\EventDispatcher\Event\AfterSuiteTested, instance of Behat\Testwork\EventDispatcher\Event\AfterSuiteAborted given in emuse\BehatHTMLFormatter\Formatter\BehatHTMLFormatter->onAfterSuiteTested() (line 474 of [excluded]/vendor/emuse/behat-html-formatter/src/Formatter/BehatHTMLFormatter.php).
I was able to resolve this issue (and a subsequent one) by changing
public function onAfterSuiteTested(AfterSuiteTested $event)
and
public function onAfterExercise(AfterExerciseCompleted $event)
to
public function onAfterSuiteTested(\Behat\Testwork\EventDispatcher\Event\SuiteTested $event)
and
public function onAfterExercise(\Behat\Testwork\EventDispatcher\Event\ExerciseCompleted $event)
Is there a reason you're using the specific classes rather than the interfaces here?
Could you please tag a release with the latest changes?
The last release was in 2015 and old code is automatically loaded when follow setup instruction.
Many improvements and bug fixes are in the master branch only now, so you have to load it directly from repo now:
"require-dev": {
"emuse/behat-html-formatter": "dev-master@dev"
},
"repositories": [
{
"url": "https://github.com/dutchiexl/BehatHtmlFormatterPlugin.git",
"type": "git"
}
]
@dutchiexl, you have been doing a great job with the formatter plugin.
Could you create a version tag - stable - and define a license for this project?
Thanks! 😄
Is there a way to print last response. This would be very useful.
When i add to my something.feature Scenario Outline
(for example this )
Scenario Outline: Overeni prihlaseni - platne username a password
When I fill in "frm-signInForm-username" with ""
When I fill in "frm-signInForm-password" with ""
When I check "frm-signInForm-remember"
And I press "Přihlásit"
Then I should not see "Neplatná kombinace uživatelského jména a hesla."
And I should see "Přihlášen uživatel: "
And I should see "Zvolte si prosím přislušný modul v menu výše."
And the "title" element should contain "ERP | Uloženka"
And I should be on "/"
And I should not see "504 Gateway Time-out"
And I should not see "chyba 404"
And I should not see "error 500"
And the "title" element should not contain "Server Error"
Then I need screenshot
And I follow "Odhlásit"
My output html have everytime opened this Scenario Outline:
Can you doing some repair?
Sorry my ignorance.
Hi @dutchiexl , would you accept another template?
I have made this one with another extension of mine:
https://rawgit.com/fonsecas72/show/master/index.html
I like your implementation and I'm willing to improve it if you are interested. I would like to add:
You don't need to commit this new template if don't want to. It is enough to me to have this features implemented.
Perhaps later we can gather our efforts in creating a better template using both templates?
Hello,
Cool stuff, but I'm missing a small feature: I have cases when I log some messages to console (using print command) and these messages are not included in the .html report (I can see them in the regular "pretty" report).
For example, when a step fails, I take a screenshot and log the path and name:
Screenshot at: D:\blabla\screenshots\2015-05-12_17-36-22_55520fe6d2a17.png
If this line would be included in the html report, maybe I could go further and change it to match a < img > tag which would actually directly display the image in the report. Am I asking too much? :)
I have only one month of experience with Behat, so I'm not capable of extending your code by myself.
If you have other suggestions, please let me know.
Thank you.
Hi there
Is it any way to get browser name in report where test was executed ?
or any additional information for example from test code
Hi guys, I wanted add screenshot to report and add your code (The facility exists to embed a screenshot into test failures.). And I have some questions to you:
What about takeScreenshot() method? I didn't find this method in your source, if it's should be my method? how I can add already exists screenshot to your Twig report?
Hello,
I have a proposition of a new feature to add :
Also, this generating would be optional and could be deactivated.
It would be also possible, if the user wants it, to generate these files after each steps even if there is no error (to keep a trace of each step of the scenario, could be useful when tests are running with a headless browser like phantomJS)
Do you think adding this feature is a good idea or it is misappropriate regarding the purpose of the plugin ?
I have a little portion of code that actually work with Selenium 2 driver (and so PhantomJS), I think it could be possible to adapt it.
I followed the list of steps to install html formatter from https://github.com/dutchiexl/BehatHtmlFormatterPlugin in docker machine. But I got the error "emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension` extension file or cl ass could not be located". Help me
I use 3 ways, how doing screenshot.
First is after passed scenario - function takeScreenShotAfterSuccessScenario(afterScenarioScope $scope)
second is for fail step - public function takeScreenShotAfterFailedStep(afterStepScope $scope)
third is for situation, when i need doing screenshot - function i_need_screenshot()
my FeatureContext.php is here:
FeatureContext.zip
What i need:
I will like in html output after passed scenario, or after fail step, or after when i use Then I need scrrenshot show link bottom from actual line in html.
I mean, this is useful function.... Can somebody doing this upgrade?
On Windows renderer option is not recognized.
YML config contains:
formatters:
html:
output_path: %paths.base%/../reports/
pretty:
output_path: %paths.base%/../reports/pretty.txt
extensions:
emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
name: html
renderer: Behat2
The Invalid Configuration Exception is thrown as follows:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized option "renderer" under "testwork.emusehtml"
Hi,
The readme specify a minimum PHP version of 5.3.x but I get the following error when using PHP 5.3.10:
Parse error: syntax error, unexpected '[' in /vagrant/sites/vendor/emuse/behat-html-formatter/src/Renderer/BaseRenderer.php on line 36
The troublemaker: if(in_array($renderer, ['Behat2', 'Twig', 'Minimal'])) {
Short array syntax was introduced in PHP 5.4 (see http://php.net/manual/en/migration54.new-features.php).
Thanks :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.