Sunil P S
Sunil P S

Reputation: 11

Pester's XML report contains only the file name, not full path

I'm new to Pester, I was testing the things locally then i got this problem. When i generate the XML report in pester it contains this line

<package name="code"><class name="code/cal" sourcefilename="cal.ps1">

but when i generate the HTML file using ReportGenerator, it gives "file does not exist (any more)". So i change the above code snippet it started giving the result without any error. i.e.,

<package name="code"><class name="code/cal" sourcefilename=".\code\cal.ps1">

i have below directory structure

root
 |_ code  #contains all the main scripts
 |_ test  #contains all the test scripts

I even tried adding this code in the AfterAll block, but the XML file gets generated only after its execution. so it's giving a file not found error.

AfterAll{
        $script_name = "cal.ps1"
        $script_path = (".\code\" + "cal.ps1")
        (Get-Content "coverage.xml").replace( $script_name , ( $script_path + $script_name ) ) | Set-Content "coverage.xml"
    }

So, is there any way for doing that change automatically?

Thanks in advance

Upvotes: 1

Views: 150

Answers (0)

Related Questions