Phpunit -我如何注释测试?

时间:2022-10-15 22:52:49

I'd like to run my tests in separate processes. Because of this, I would like to annotate my tests with "@runTestsInSeparateProcesses". However, I have never annotated Phpunit tests before and I haven't been able to find a good description of where to actually put the annotations. I've seen what the different annotations do, just not where to put them. Could someone please give me an example?

我想在不同的过程中运行我的测试。因此,我想用“@ runtestsinsecateprocess”来注释我的测试。但是,我以前从来没有注释过Phpunit测试,而且我也没有能够找到一个很好的说明在哪里放置注释。我已经看到了不同的注释做了什么,而不是放在哪里。能给我举个例子吗?

Thanks!

谢谢!

1 个解决方案

#1


4  

Annotations are applied to your test-case's docblock:

将注释应用于测试用例的docblock:

/**
 * Short Description
 * 
 * @param string $input The test input
 * 
 * @return bool The result
 * 
 * @runTestsInSeparateProcesses
 */
public function test_myMethod ($input) {
  // Test code here
}

Read more about DocBlocks: https://docs.phpdoc.org/

阅读更多有关docblock: https://docs.phpdoc.org/。

#1


4  

Annotations are applied to your test-case's docblock:

将注释应用于测试用例的docblock:

/**
 * Short Description
 * 
 * @param string $input The test input
 * 
 * @return bool The result
 * 
 * @runTestsInSeparateProcesses
 */
public function test_myMethod ($input) {
  // Test code here
}

Read more about DocBlocks: https://docs.phpdoc.org/

阅读更多有关docblock: https://docs.phpdoc.org/。