Java 针对Maven测试将PowerMockto与SCALA集成的问题

Java 针对Maven测试将PowerMockto与SCALA集成的问题,java,scala,maven,junit,powermock,Java,Scala,Maven,Junit,Powermock,我正试着用maven运行我的测试。测试是用scala编写的 我已经将jar包含在pom.xml中,以包含powermockito <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> <version>1.4.6</version>

我正试着用maven运行我的测试。测试是用scala编写的

我已经将jar包含在pom.xml中,以包含powermockito

   <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <version>1.4.6</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-core</artifactId>
        <version>1.4.6</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>1.4.6</version>
        <scope>test</scope>
    </dependency>
不知何故,测试在运行时没有执行

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.zombie.server.XMLWithZombieTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.204 sec
我的测试如下:

import org.junit.runner.RunWith
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test
import org.junit.Before
import org.junit.Assert._

@RunWith(classOf[PowerMockRunner])
class XMLWithZombieTest {

  var sb: StringBuilder = _
  var lb: ListBuffer[String] = _

  @Before def initialize() {
    sb = new StringBuilder("ScalaTest is ")
    lb = new ListBuffer[String]
  }

  @Test def verifyEasy() { // Uses JUnit-style assertions
    sb.append("easy!")
    assertEquals("ScalaTest is easy!", sb.toString)
    assertTrue(lb.isEmpty)
    lb += "sweet"
    try {
      "verbose".charAt(-1)
      fail()
    }
    catch {
      case e: StringIndexOutOfBoundsException => // Expected
    }
  }
}
一旦我删除RunWith语句,我的测试就开始执行,但当我有RunWith语句时,它就会被忽略,这是PowerMockito所必需的

我正在使用下面的maven surefire插件

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <excludes>
                        <exclude>**/*Suite*.java</exclude>
                    </excludes>
                    <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
                </configuration>
            </plugin>

org.apache.maven.plugins
maven surefire插件
2.6
**/*套件*.java
-Xms256m-Xmx512m-XX:MaxPermSize=256M
我将PowerMockito与Java集成在一起,效果很好

任何投入都会有帮助。我错过了什么吗。如果需要更多细节,请告诉我


谢谢

你能发布实际测试吗?在上面添加了样本测试。
import org.junit.runner.RunWith
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test
import org.junit.Before
import org.junit.Assert._

@RunWith(classOf[PowerMockRunner])
class XMLWithZombieTest {

  var sb: StringBuilder = _
  var lb: ListBuffer[String] = _

  @Before def initialize() {
    sb = new StringBuilder("ScalaTest is ")
    lb = new ListBuffer[String]
  }

  @Test def verifyEasy() { // Uses JUnit-style assertions
    sb.append("easy!")
    assertEquals("ScalaTest is easy!", sb.toString)
    assertTrue(lb.isEmpty)
    lb += "sweet"
    try {
      "verbose".charAt(-1)
      fail()
    }
    catch {
      case e: StringIndexOutOfBoundsException => // Expected
    }
  }
}
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <excludes>
                        <exclude>**/*Suite*.java</exclude>
                    </excludes>
                    <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
                </configuration>
            </plugin>