mstest의 trx 파일을 html로 변환하기 위해 xsl을 작성했습니다.
이 후 link 클래스 이름과 각 클래스에 대한 통과 및 실패 수를 출력 할 수 없습니다.
나는 어디가 잘못되었는지 잘 모르겠습니다. 스타일 시트는 링크의 동일한 입력 파일에 적용됩니다.
감사합니다. 더 원하는 출력이 없기 때문에mstest의 trx 파일 변환을 위해 xslt의 키 사용
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:t="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
<xsl:param name="today"></xsl:param>
<xsl:param name="results"></xsl:param>
<xsl:param name="pass" select="'Passed'"/>
<xsl:param name="fail" select="'Failed'"/>
<xsl:param name="incon" select="'Inconclusive'"/>
<xsl:param name="error" select="'Error'"/>
<xsl:key name="class-key" match="@className" use="."/>
<xsl:variable name="unique-classes" select="//t:TestMethod/@className[generate-id(.)=generate-id(key('class-key',.))]" />
<xsl:template match="/">
<html>
<head>
<script type="text/javascript">
//Some javascript code
</script>
</head>
<body style="font-family:Verdana; font-size:10pt">
<a href="coverage.htm">Coverage Summary</a>
<xsl:call-template name="summary" />
<xsl:call-template name="details2" />
</body>
</html>
</xsl:template>
<xsl:template name="summary">
<h3>Test Summary</h3></code>
<table style="width:640;border:1px solid black;font-family:Verdana; font-size:10pt">
<tr>
<td style="font-weight:bold;">Total</td>
<td style="font-weight:bold;">Failed</td>
<td style="font-weight:bold;">Passed</td>
<td style="font-weight:bold;">Inconclusive</td>
<td style="font-weight:bold;">Error</td>
</tr>
<tr>
<td >
<xsl:value-of select="/t:TestRun/t:ResultSummary/t:Counters/@total"/>
</td>
<td style="background-color:pink;">
<xsl:value-of select="/t:TestRun/t:ResultSummary/t:Counters/@failed"/>
</td>
<td style="background-color:lightgreen;">
<xsl:value-of select="/t:TestRun/t:ResultSummary/t:Counters/@passed"/>
</td>
<td style="background-color:lightblue;">
<xsl:value-of select="/t:TestRun/t:ResultSummary/t:Counters/@inconclusive"/>
</td>
<td style="background-color:yellow;">
<xsl:value-of select="/t:TestRun/t:ResultSummary/t:Counters/@error"/>
</td>
</tr>
</table>
</xsl:template>
<xsl:template name="details2">
<h3>Unit Test Results</h3>
<table border="0" style="width:640;border:1px solid black;font-family:Verdana; font-size:10pt;">
<tr>
<td></td>
<td id="data" style="font-weight:bold;">Test Name</td>
<td id="data" style="font-weight:bold;">Result</td>
<td id="data" style="font-weight:bold;">Duration</td>
</tr>
<xsl:for-each select="$unique-classes">
<xsl:sort />
<xsl:variable name="curClass" select="."/>
<xsl:variable name="parentId" select="generate-id(./..)" />
<xsl:variable name="currentId" select="generate-id(.)" />
<tr id="{$parentId}">
<td id="{$currentId}"
style="font-weight:bold; cursor:pointer;"
onClick="toggleDetail(this)">[+]</td>
<xsl:sort select="@name"/>
<xsl:variable name="testid" select="../@id"/>
<xsl:with-param name="testid" select="."/>
<xsl:with-param name="curClass" select="."/>
<xsl:call-template name="groups" />
</tr>
<xsl:call-template name="classRunsDetail">
<xsl:with-param name="curClass" select="."/>
</xsl:call-template>
<tr id="{$currentId}-end" style="display:none;">
<td style="border-bottom:0px solid black;height:1px;background-color:black" colspan="4"></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="classRunsDetail">
<xsl:param name="curClass"/>
<xsl:variable name="parentId" select="generate-id(.)" />
<xsl:for-each select="//t:UnitTest/t:TestMethod[@className=$curClass]">
<xsl:sort select="@name"/>
<xsl:variable name="testid" select="../@id"/>
<xsl:for-each select="//t:UnitTestResult[@testId=$testid]">
<tr id="{$parentId}">
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="@outcome = $fail">background-color:pink;</xsl:when>
<xsl:when test="@outcome = $pass">background-color:lightgreen;</xsl:when>
<xsl:when test="@outcome = $incon">background-color:lightblue;</xsl:when>
<xsl:otherwise>background-color:yellow;</xsl:otherwise>
</xsl:choose>
display:none;
</xsl:attribute>
<td></td>
<td id="data">
<xsl:value-of select="@testName"/>
</td>
<td id="data">
<xsl:choose>
<xsl:when test="@outcome = $fail">FAILED</xsl:when>
<xsl:when test="@outcome = $pass">Passed</xsl:when>
<xsl:when test="@outcome = $incon">Not Run</xsl:when>
<xsl:otherwise>Error</xsl:otherwise>
</xsl:choose>
</td>
<td id="data">
<xsl:value-of select="@duration"/>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:key name="class" match="t:TestMethod" use="@className"/>
<xsl:key name="result" match="t:UnitTestResult" use="@testName"/>
<xsl:template name="groups" match="t:TestMethod[count(.|key('class',@className)[1])=1]">
<xsl:variable name="result" select="key('result',key('class',@className)/@name)"/>
<td valign="bottom" style="background-color:beige;font-weight:bold;" colspan="3">
<xsl:value-of select="@className"/>
</td>
<td>
<xsl:value-of select="count($result[@outcome='Passed'])"/>
</td>
<td>
<xsl:value-of select="count($result[@outcome='Failed'])"/>
</td>
<td>
<xsl:value-of select="count($result[@outcome='Inconclusive'])"/>
</td>
</xsl:template>
</xsl:stylesheet>
정말 대단했습니다. 알레한드로 감사합니다. 그건 그렇고 왜 각자를 위해 문제를 일으키는 지 말해 주시겠습니까? 나는 배울 것을 매우 좋아한다. – Sidd
@ 시드 : 'for-each'지시가 문제라고 생각하지 않지만, 그들은 정말로 유지 보수를 방해했다. 선언적 패러다임에서, 당신은 당신의 입출력을 알아야하고, 그 관계를 표현해야합니다. 또한이 특정 변형은 population이라고도 할 수 있습니다. 이미 레이아웃 (XHTML)이 있고 데이터로 채워야합니다. 당신은 앵커를 넣을 수 있습니다 (@id라고 말하면됩니다). "identity transformation"(찾을 때)에서 그들을 찾을 때 (document() 함수로 여러개의 문서 입력) 데이터를 삽입하십시오. 이 사이트에서보세요 : http://www.aranedabienesraices.com.ar –