Giter Site home page Giter Site logo

cucumber-junit's Introduction

cucumber-junit's People

Contributors

nalbion avatar ninjatux avatar sonyschan avatar stjohnjohnson avatar szikszail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cucumber-junit's Issues

Improvement: support for custom properties

In case of automating the failure investigation and filter out or handle common errors (element not found, wait timeout or common application specific errors) we need to sign somewhere in the JSON, that what type of error happened, what the cause of the failure.

In the JUnit XML format it is not a problem, using properties in testsuite tags.

If I make a hook and process the failing steps in my TA framework, there is no way to include the common error type or any custom properties to cucumber JSON. If I make a custom formatter, what makes an extended cucumber JSON format, that could be a solution. It could add a properties attribute to scenario's object.

In this case we have to improve cucumber-junit to support these custom properties and pass through them as tags passed through now.

Would this be a good improvement and useful to others, or not?
What do you think @stjohnjohnson ?

If you think it is a good idea, I will implement it immediately.

Tests fail if any output from either console or util.log

I had some trouble getting things to work until I realized that any output at all to console (using console.log) or require("util").log("text") both create exceptions.

I have noticed that -json starts normal output with an array.

I am working with an express app, and there is some logging. I realize that probably I should go ahead and remove any logging of this nature some day, but for now, I'd rather ask for a feature or parameter of some sort to ignore this type of text. Let me know if you're interested and I can send you some output from -json to test with.

If there is something completely wrong that I'm doing and I need to run the initial command differently, please let me know and perhaps add as instructions for someone else on the wiki ?

Thanks.. for my first attempt, this did the trick.. Thanks for writing it.

Parse Error On Cucumber JS output

I'm currently running this:

node_modules/cucumber/bin/cucumber.js ./test --format=json | node_modules/cucumber-junit/bin/cucumber-junit

The yield of - node_modules/cucumber/bin/cucumber.js ./test --format=json - is this:

[
  {
    "id": "Pageload-and-Log-in",
    "name": "Pageload and Log in",
    "description": "As a "app" user\nI should find a fully loaded home page\nand should be able select a bet when not logged in",
    "line": 1,
    "keyword": "Feature",
    "uri": "path/to/feature",
    "elements": [
      {
        "name": "Confirm the page title",
        "id": "Pageload-and-Log-in;confirm-the-page-title",
        "line": 6,
        "keyword": "Scenario",
        "description": "",
        "type": "scenario",
        "steps": [
          {
            "name": "I go on the website \"http://www.url.com\"",
            "line": 7,
            "keyword": "Given ",
            "result": {
              "duration": 1509723585,
              "status": "passed"
            },
            "match": {}
          },
          {
            "name": "I check the title of the website",
            "line": 8,
            "keyword": "When ",
            "result": {
              "duration": 6951044,
              "status": "passed"
            },
            "match": {}
          },
          {
            "name": "the page title should be \"My Title\"",
            "line": 9,
            "keyword": "Then ",
            "result": {
              "duration": 40760,
              "status": "passed"
            },
            "match": {}
          }
        ]
      }
    ]
  }
]

But Cucumber-Junit - node_modules/cucumber-junit/bin/cucumber-junit - returns this:

SyntaxError: Unexpected token
at Object.parse (native)
at cucumberJunit (/Users/leonard/Documents/projects/BDD-test-build/node_modules/cucumber-junit/lib/cucumber_junit.js:115:29)
at Socket. (/Users/leonard/Documents/projects/BDD-test-build/node_modules/cucumber-junit/bin/cucumber-junit:15:26)
at Socket.emit (events.js:117:20)
at _stream_readable.js:938:16
at process._tickCallback (node.js:419:13)

Any ideas why?

path to cucumber-junit in sample on wiki

Hi there...
I'm trying to use this module to work with nodejs and jenkins.

The following command has an error for someone who doesn't have cucumber-junit loaded into --global.

node_modules/.bin/cucumber-js --format=json | cucumber-junit > output_JUnit.xml

needs to read

node_modules/.bin/cucumber-js --format=json | node_modules/./bin/cucumber-junit > output_JUnit.xml

or of course, it might work by installing into --global in the first place (not my particular preference).

Respect "hidden" tag

The JSON generated by cucumber-js for my tests has Before and After steps that are tagged in the JSON as "hidden". It would be nice if cucumber-junit respected the the "hidden" tag and left these steps out of the generated xml.

Example excerpt:

"steps": [
          {
            "keyword": "Before ",
            "hidden": true,
            "result": {
              "duration": 6105808,
              "status": "passed"
            },
            "match": {}
          },
          {
            "name": "I log in as user \"username\" and password \"password\"",
            "line": 9,
            "keyword": "When ",
            "result": {
              "duration": 33224808,
              "status": "passed"
            },
            "match": {}
          },

Fails if any output other than json

I have attempted to use cucumber-junit to convert the output of cucumberjs from json to junit, but I'm having a problem. The use that you indicate, piping the output of cucumberjs to cucumber-junit, fails because some packages I use and some of my code print debug statements to the console along with the json. I removed my console prints but the underlying packages still print. Writes to stderr don't appear to cause a problem but if it gets printed to stdout then your json parser stops with an error.

So I have 2 questions, either of which would enable me to use your package successfully.

  1. Is it possible to tell cucumber-junit to ignore everything except the json?
  2. Is it possible to have cucumber-junit take its input from a file instead of piping from a stream? When cucumberjs writes the json to a filethe other stdout/stderr prints are stripped out, so this solution would work for me.

Run example crashes in a special case

$ node_modules/.bin/cucumber-js --format=json | node_modules/.bin/cucumber-junit > output_JUnit.xml

This example crashes because if you write something in the stdout.
see:

> cucumber-js src/features/**/*.feature --format=json | cucumber-junit > output_JUnit.xml

undefined:1
logs in
^

SyntaxError: Unexpected token l in JSON at position 0
    at JSON.parse (<anonymous>)
    at cucumberJunit (C:\projects\gws-v3\projects\aggregators\gws-app-telemetry\functionnal\node_modules\cucumber-junit\lib\cucumber_junit.js:204:29)
    at Socket.<anonymous> (C:\projects\gws-v3\projects\aggregators\gws-app-telemetry\functionnal\node_modules\cucumber-junit\bin\cucumber-junit:39:26)
    at Socket.emit (events.js:202:15)
    at endReadableNT (_stream_readable.js:1132:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)

Mention about it would be nice addition in the doc no?

Workaround:
cucumber-js src/features/**/*.feature --format=json:results/functionnalOutput.json && cat results/functionnalOutput.json | cucumber-junit > results/output_JUnit.xml

Scenario as single testcase, rather than Given/When/Then

image

I don't know if this is intended or not. Basically, each step (Given/When/Then/And) component of a scenario is counted as a testcase. I would prefer each scenario within a feature to be treated as a testcase. The reason being, that I re-use each Given, When and Then often, which in the report artificially increases the actual test count.

Do you think this would be a reasonable change (I would try to implement it)? Or is this an optional feature?

XML parsing error if more than one feature

If you have more than one feature then the XML output is not wrapped in a element as proposed in the junit XSD and Jenkins throws an "The markup in the document following the root element must be well-formed"-error.

Cucumber 2

I can't get this to work in Cucumber 2. Would you mind trying, to conclude if I i've made any mistakes?

Testsuites summary

According to this <testsuites> tag can get some optional attributes like total number of successful tests from all testsuites or total time, but what I get is <testsuites> without any attributes. It would be helpful if I could get a meaningful summary in this tag

undefined steps should be interpreted as a fail

I don't think that undefined steps should be glossed over - if the test steps have not been implemented, the scenario can not be considered as passing - people need to know that something needs to be fixed or worked on.

Cannot read property 'length' of undefined

Getting this when trying to run ./node_modules/.bin/cucumber-junit > tests/features/cucumber_report.xml

\node_modules\protractor-cucumber-junit\lib\cucumber_junit.js:24
    var lastAssert = stepJson.assertions.length - 1;
                                        ^
Cannot read property 'length' of undefined

What I'm doing wrong?

Cannot read property 'duration'

Hello guys.
Recently I was trying to convert cucumber .json report into .xml file using following wrapper. After the successful installation I am facing one issue which I cannot overcome or google something similar on I-net. When I run following command:

$ node_modules/.bin/cucumber-js --format=json | node_modules/.bin/cucumber-junit > output_JUnit.xml

I'm getting following error output:

if (stepJson.result.duration) {
^

TypeError: Cannot read property 'duration' of undefined
at convertStep (/Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:37:24)
at /Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:104:28
at Array.forEach (native)
at convertScenario (/Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:101:10)
at /Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:132:28
at Array.map (native)
at convertFeature (/Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:131:10)
at /Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:153:36
at Array.forEach (native)
at cucumberJunit (/Users/Sergiy/node_modules/cucumber-junit/lib/cucumber_junit.js:152:22)

Please tell me what kind of additional information I should post under this post (environment) for you guys that can help to find an answer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.