PhpStorm에서 PHPUnit 단위테스트 하기
1. Create New Project > PHPUnit 프로젝트 생성하기
2. 프로젝트 패널에서 단위테스트할 php파일(PHPUnit.php)을 만듭니다.
3. PHPUnit 단위테스트를 위한 코드를 작성해봅니다.
http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html
Example 4.3: Exploiting the dependencies between tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<code>class DependencyFailureTest extends PHPUnit_Framework_TestCase
{
public function testOne()
{
$this–&gt;assertTrue(FALSE);
}
/**
* @depends testOne
*/
public function testTwo()
{
}
}</code>
|
4. 탑메뉴 > Run > Edit Configurations
5. 탑메뉴 > Run > Run 실행하기
Run 실행하기에 앞서 PhpStorm PHP 설정이 되어 있어야합니다.
– 탑메뉴 > File > Settings > PHP
– Run 실행 > PHP Fix 설정
Run 실행하기
위 내용과 다음의 참조 링크의 예제 4.3 을 비교해서 동일한 결과가 나온다면 PHPUnit 단위테스트가 정상적으로 작동한것입니다.
http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html
Example 4.3: Exploiting the dependencies between tests
다른 예제 코드를 테스트 보고 결과값을 확인해보세요
참조 : http://blogs.jetbrains.com/webide/2009/12/phpunit-support/