PHPUnitManual:18.1

From 흡혈양파의 번역工房
Revision as of 09:46, 4 July 2013 by Onionmixer (talk | contribs) (PHPUnit 18.1 테스트 결과 (XML) 페이지 추가)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
18.1 테스트 결과 (XML)

PHPUnit 이 작성하는 테스트 결과의 XML log 파일은, Apache Ant 의 JUnit 태크스 가 사용하는 방식을 참고로 하고 있습니다. 다음 예는 ArrayTest 테스트가 생성한 XML log 파일입니다.

  <?xml version="1.0" encoding="UTF-8"?>
  <testsuites>
    <testsuite name="ArrayTest"
	       file="/home/sb/ArrayTest.php"
	       tests="2"
	       assertions="2"
	       failures="0"
	       errors="0"
	       time="0.016030">
      <testcase name="testNewArrayIsEmpty"
		class="ArrayTest"
		file="/home/sb/ArrayTest.php"
		line="6"
		assertions="1"
		time="0.008044"/>
      <testcase name="testArrayContainsAnElement"
		class="ArrayTest"
		file="/home/sb/ArrayTest.php"
		line="15"
		assertions="1"
		time="0.007986"/>
    </testsuite>
  </testsuites>


다음 XML log 파일은, 테스트 클래스 FailureErrorTest 의 테스트 testFailure 와 testError 가 출력한 것입니다. 실패와 에러가 어떻게 표시되는지를 확인할 수 있습니다.

  <?xml version="1.0" encoding="UTF-8"?>
  <testsuites>
    <testsuite name="FailureErrorTest"
	       file="/home/sb/FailureErrorTest.php"
	       tests="2"
	       assertions="1"
	       failures="1"
	       errors="1"
	       time="0.019744">
      <testcase name="testFailure"
		class="FailureErrorTest"
		file="/home/sb/FailureErrorTest.php"
		line="6"
		assertions="1"
		time="0.011456">
	<failure type="PHPUnit_Framework_ExpectationFailedException">
	  testFailure(FailureErrorTest)
	  Failed asserting that &lt;integer:2&gt; matches expected value &lt;integer:1&gt;.

	  /home/sb/FailureErrorTest.php:8
	</failure>
      </testcase>
      <testcase name="testError"
		class="FailureErrorTest"
		file="/home/sb/FailureErrorTest.php"
		line="11"
		assertions="0"
		time="0.008288">
	<error type="Exception">testError(FailureErrorTest)
	Exception:

	/home/sb/FailureErrorTest.php:13
	</error>
      </testcase>
    </testsuite>
  </testsuites>


Notes