martijnvandervlag / newman-reporter-junitfull

A Newman JUnit Reporter providing full reports (without aggregation of results)
Apache License 2.0
13 stars 10 forks source link

Error: Missing attribute value. attribute: {value}, parent: <property> #2

Open abilous86 opened 4 years ago

abilous86 commented 4 years ago

Hello,

I'm receiving the following error when running collection using Newman with junitfull reporter:

/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/xmlbuilder/lib/XMLAttribute.js:14
        throw new Error("Missing attribute value. " + this.debugInfo(name));
        ^

Error: Missing attribute value. attribute: {value}, parent: <property>
    at new XMLAttribute (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/xmlbuilder/lib/XMLAttribute.js:14:15)
    at XMLElement.module.exports.XMLElement.attribute (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/xmlbuilder/lib/XMLElement.js:72:35)
    at XMLElement.module.exports.XMLElement.att (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/xmlbuilder/lib/XMLElement.js:100:19)
    at /usr/local/lib/node_modules/newman-reporter-junitfull/lib/index.js:107:15
    at arrayEach (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/lodash/lodash.js:516:11)
    at Function.forEach (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/lodash/lodash.js:9342:14)
    at /usr/local/lib/node_modules/newman-reporter-junitfull/lib/index.js:104:7
    at arrayEach (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/lodash/lodash.js:516:11)
    at Function.forEach (/usr/local/lib/node_modules/newman-reporter-junitfull/node_modules/lodash/lodash.js:9342:14)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/newman-reporter-junitfull/lib/index.js:58:5)
    at EventEmitter.emit (/usr/local/lib/node_modules/newman/node_modules/eventemitter3/index.js:203:33)
    at done (/usr/local/lib/node_modules/newman/lib/run/index.js:280:29)
    at /usr/local/lib/node_modules/newman/node_modules/postman-runtime/lib/backpack/index.js:58:34
    at PostmanCollectionRun._process (/usr/local/lib/node_modules/newman/node_modules/postman-runtime/lib/runner/run.js:163:13)
    at PostmanCollectionRun.<anonymous> (/usr/local/lib/node_modules/newman/node_modules/postman-runtime/lib/runner/run.js:169:76)
    at ontimeout (timers.js:498:11)

I have 10 collection in my workspace and only one of them returns this error. I even tried to execute a single request from the collection but still run is failing with the same error( all other collections are executed without any issues).

anishkny commented 4 years ago

Same error

arauchberger commented 4 years ago

me too

arauchberger commented 4 years ago

i'm using a collection with about 150 Request/Tests when i suddenly ran into this error. i created a one-request-only collection -> works fine, but it's a bit hard to analyse which request/test exactly is causing this error.

but i could attach the collection/env, if you need.

thanks

gh3rann commented 4 years ago

Same comment, I can provide evidence if needed. For me it happens evey time.

FrancisBourgault commented 3 years ago

I got that error when I used a variable inside to define the test name.

pm.test(pm.info.requestName+"-Status validation")

UPDATE: This was actually cause by extracting a properties from the response that didn't exist. It's fix for me.

eugengaspar commented 3 years ago

Hello guys! Any update here, by any chance? Lately, I'm also encountering the same issue:

Pixcell commented 3 years ago

Same error here. One collection, 280 requests, a couple of tests per request. I have no new information, just following the thread to see if there is a resolution. Simple JUnit reporter works perfectly fine, but is pretty useless since the tests are all aggregated

tboulord commented 3 years ago

Hello, I had the same issue. After noticing that I only had this error on a specific environment (even on a simple request without tests), I fixed this issue by recreating the exact same environment.

Something to do with a corrupted environment json file ?

b-for commented 3 years ago

I identified 2 situations which the reporter cannot handle and lead to the above mentioned error.

  1. Empty values for environment variables in the environment file, if they are represented by the null string. Changing this in the json file to an empty string value with 2 double quotes, will fix the issue: null => "". Or regenerate the file with a recent Postman version, this should also generate the empty value with double quotes.

  2. From within the test code, creating an environment variable (or changing the value of an existing, I guess), with the result of a function that does not return a value.

Example:

pm.environment.set("sessionid", pm.response.json().session); Say the response json does not contain the session field. Then the sessionid environment variable will be set to null. And the reporter will fail.

A possible solution: test before you assign:

if (pm.response.json().session) { pm.environment.set("sessionid", pm.response.json().session); }

vjppaz commented 3 years ago

any update or workaround?

It is working when I execute the test on local (JUnitResult file was generated) but when execution happens in Azure Pipeline this error occurs

vjppaz commented 3 years ago

SOLVED ON MY END!

The reason why it keeps on failing on my end is because there are requests from my collection that requires a "FILE". After fixing the path using work directory my Test Automation in Azure Pipeline is now working!

naasse commented 2 years ago

This is a really easy fix. I use a forked version of this repo where the same bug exists.

See my PR https://github.com/bhecquet/newman-reporter-xunit/pull/10

I'd suggest somebody who wants this repo fixed request the same here.

vjppaz commented 2 years ago

workaround: make your that you don't have any variable or environment variable that has a "NULL" value.

If only the XMLAttribute.js line#14 has this below line of code instead the current one, we would never have this kind of exception:

      if (name == null) {
        this.name = "unknown";
      }
      else {
    this.name = this.stringify.attName(name);
      }
      if (value == null) {
        this.value = "null";
      }
      else {
        this.value = this.stringify.attValue(value);
      }
JoSSte commented 1 year ago

I identified 2 situations which the reporter cannot handle and lead to the above mentioned error.

  1. Empty values for environment variables in the environment file, if they are represented by the null string. Changing this in the json file to an empty string value with 2 double quotes, will fix the issue: null => "". Or regenerate the file with a recent Postman version, this should also generate the empty value with double quotes.
  2. From within the test code, creating an environment variable (or changing the value of an existing, I guess), with the result of a function that does not return a value.

Example:

pm.environment.set("sessionid", pm.response.json().session); Say the response json does not contain the session field. Then the sessionid environment variable will be set to null. And the reporter will fail.

A possible solution: test before you assign:

if (pm.response.json().session) { pm.environment.set("sessionid", pm.response.json().session); }

I experienced the exact same solution as this - maybe the smarter solution would be to post a proper warning message so we can clean up our testsuites?

hvitis commented 10 months ago

SOLVED ON MY END!

The reason why it keeps on failing on my end is because there are requests from my collection that requires a "FILE". After fixing the path using work directory my Test Automation in Azure Pipeline is now working!

👆🏻 Solution