Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to set the html report name to collection name being run #62

Open
Scott-Emberson opened this issue May 30, 2019 · 3 comments · May be fixed by #87
Open

Add the ability to set the html report name to collection name being run #62

Scott-Emberson opened this issue May 30, 2019 · 3 comments · May be fixed by #87

Comments

@Scott-Emberson
Copy link
Contributor

Add an additional option onto the HTML report location so you can have the code set the HTML name to the collection being run.

I have started to look at it, but unsure where I could pick up the collection name.

@Scott-Emberson Scott-Emberson changed the title Add the ability to set the html report name to collection Add the ability to set the html report name to collection name being run May 30, 2019
@yossarian123
Copy link
Contributor

I think the collection name is passed into the GetTestRunner method:

function GetToolRunner(collectionToRun: string) {

@Scott-Emberson
Copy link
Contributor Author

Thanks @yossarian123 I am not too good with ts but would this work?

if (reporterReportNameToCollectionName === true) { let reporterHtmlExport = tl.getPathInput('reporterHtmlExport'); newman.argIf(typeof reporterHtmlExport != 'undefined' && tl.filePathSupplied('reporterHtmlExport'.concat("\\",collectionToRun.toString())), ['--reporter-html-export', reporterHtmlExport]); let reporterJsonExport = tl.getPathInput('reporterJsonExport'); newman.argIf(typeof reporterJsonExport != 'undefined' && tl.filePathSupplied('reporterJsonExport'.concat("\\",collectionToRun.toString())), ['--reporter-json-export', reporterJsonExport]); let reporterJUnitExport = tl.getPathInput('reporterJUnitExport', false, false); newman.argIf(typeof reporterJUnitExport != 'undefined' && tl.filePathSupplied('reporterJUnitExport'.concat("\\",collectionToRun.toString())), ['--reporter-junit-export', reporterJUnitExport]); }

@carlowahlstedt
Copy link
Owner

@Scott-Emberson if I understand this correctly you'd like to:

  1. Add a checkbox labeled: "Set HTML Report Name to the Collection Name"
  2. When running newman, insert the collection name as the name of the report generated

Things that seem added based on your code snippet from above:

  1. You want to be able to set "Reporter Html Export", "Reporter Json Export", and "Reporter JUnit Export"

Questions I'm unsure about:

  1. Each of the above listed export options are paths, where the help says the following and all are similar: "Specify a path where the output JSON file will be written to disk. If not specified, the file will be written to newman/ in the current working directory." So my question is, can you specify a file when the docs say path?
  2. Given that your setting all three, would it be helpful to append the type after the collection name for clarity? So [collection-name]-json.json

Steps to complete this:

  1. Add a boolean option in task.json for the setting
  2. Get the option globally and reuse it
  3. Your code snippet is close. You need to:
    1. reorg the 3 types being picked up now to be together
    2. make sure we're using if/else so we pickup both cases
    3. try to reduce the code to be reused as much as possible where it is still clear what is going on

A quick draft of your section of code refactored would be something like:

    let reporterHtmlExport = tl.getPathInput('reporterHtmlExport'); 
    let reporterJsonExport = tl.getPathInput('reporterJsonExport'); 
    let reporterJUnitExport = tl.getPathInput('reporterJUnitExport', false, false); 

    let useCollectionNameForReportName;
    if (useCollectionNameForReportName === true) {
        newman.argIf(typeof reporterHtmlExport != 'undefined' && tl.filePathSupplied('reporterHtmlExport'), ['--reporter-html-export', reporterHtmlExport.concat("\\", collectionToRun)]);
        newman.argIf(typeof reporterJsonExport != 'undefined' && tl.filePathSupplied('reporterJsonExport'), ['--reporter-json-export', reporterJsonExport.concat("\\", collectionToRun)]);
        newman.argIf(typeof reporterJUnitExport != 'undefined' && tl.filePathSupplied('reporterJUnitExport'), ['--reporter-junit-export', reporterJUnitExport.concat("\\", collectionToRun)]);
    }
    else {
        newman.argIf(typeof reporterHtmlExport != 'undefined' && tl.filePathSupplied('reporterHtmlExport'), ['--reporter-html-export', reporterHtmlExport]); 
        newman.argIf(typeof reporterJsonExport != 'undefined' && tl.filePathSupplied('reporterJsonExport'), ['--reporter-json-export', reporterJsonExport]); 
        newman.argIf(typeof reporterJUnitExport != 'undefined' && tl.filePathSupplied('reporterJUnitExport'), ['--reporter-junit-export', reporterJUnitExport]);
    }

@satano satano linked a pull request Aug 31, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants