//to execute the bat file directly
exec('c:\WINDOWS\system32\cmd.exe /c START test.bat');
// OR to read Only the content of the batch file
// the bat file label
$batname = "test.bat" ;
$output = exec("c:\\windows\\system32\\cmd.exe /c $batname");
echo $output ;
正在运行Properties
给我:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
但是,在src / test / scala下有几个应该被发现并运行的测试。
我甚至试过运行mvn test
,只是为了看看是否有任何显示。结果如预期:
Discovery starting.
Discovery completed in 265 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 283 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
No tests were executed.
那么,他们怎么没被发现?我的文件都名为* Test.scala,编写方式与scalatest documentation相同。
答案 0 :(得分:3)
在我当前的项目中,我们在pom.xml中有以下配置:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<phase>test-compile</phase>
</execution>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<stdout>W</stdout>
</configuration>
<executions>
<execution>
<id>scala-test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
因为很容易猜到第一个插件负责编译和资源处理,而第二个插件只在测试目标期间运行它们。