Home > Software engineering >  NUnit Console Runner pass XSLT parameters
NUnit Console Runner pass XSLT parameters

Time:08-24

When using the Console Runner, I am using an XSLT transform to convert the NUnit XML output to a custom HTML report using transform with --result option. I need to access some environment variables within the XSLT file, and the only way I know of doing that is to pass them as parameters to the transform. Is there a way that I can pass parameters to the XSLT transform from the command-line? Or is there some other way I can do this?

CodePudding user response:

If you can integrate an XSLT 2 or 3 processor in your NUnit console runner (or it directly uses one, I don't know) then there is an XPath function to access environment variables https://www.w3.org/TR/xpath-functions/#func-environment-variable. Using XSLT 1.0 processors you would need to use processor specific extension function mechanism to call into the underlying platform (e.g. Java, .NET) to read out an environment variable value.

CodePudding user response:

I think I may have found a solution. I can pass the environment variables to NUnit as parameters that I want to have in my HTML report. At the end of the test run, the result XML file will contain the parameters containing my env variables. The XSLT can then get those parameters from the XML file and format them into the HTML file.

  • Related