Using gtest in jenkins

前端 未结 6 1890
情话喂你
情话喂你 2020-12-24 12:35

I successfully run my unit test with google test in Jenkins, but I don\'t know how to show the .xml file generated by gtest. It is said that gtest satisfies the JUnit format

6条回答
  •  死守一世寂寞
    2020-12-24 12:46

    Here is a windows batch version for converting the google-test "notRun" to junit "skipped" via windows batch. I know that there are more elegant ways, but this one only requires windows batch and does the job

    rem convert gtest xml to junit compatible format (replace notRun by skipped)
    IF EXIST  %INTEXTFILE% (
        IF EXIST %OUTTEXTFILE% (
            del %OUTTEXTFILE%
            waitfor fileSystemToDoItsStuff /t 1
        )
        FOR /f "tokens=1,* delims=¶" %%A IN ( '"type %INTEXTFILE%"') DO (
            ECHO."%%A" | findstr /C:"DISABLED_">nul & IF ERRORLEVEL 1 (
                SET modified=%%A
            ) ELSE (
                SET string=%%A
                SET modified=!string:/^>=^>^^!
            )
            ECHO !modified!>> %OUTTEXTFILE%
        )
        del %INTEXTFILE%
        waitfor fileSystemToDoItsStuff /t 1
        move %OUTTEXTFILE% %INTEXTFILE%
    )
    

提交回复
热议问题