0

我们有几个 Spock 测试,当在构建中一起运行时,由于“永久空间”而失败。我应该注意,有些测试确实通过了,有些则没有。我做了明显的第一步,并尝试增加 permgen 和 maxPermSize 的 java 参数,但无济于事。为此,我在 teamCity 中“构建参数”,创建了一个名为“env.JAVA_OPTS”的新参数,并将此字符串作为值:

-XX:MaxPermSize=256m 

我们使用 Ant 作为构建工具。这是运行测试的目标。顺便说一句,我确实在分​​叉模式下尝试过:

<target name="test" depends="compileTests">
        <junit>
          <formatter type="plain" usefile="false" />
          <classpath path="${testBuildDir}" />
          <classpath refid="classpath" />  
                  <classpath path="${deployClassesDir}" />        
          <batchtest>
            <fileset dir="${testBuildDir}">
                <include name="**/*Spec.class"/>                                
            </fileset>
          </batchtest>
        </junit>
    </target>

我尝试通过忽略测试类中的所有测试并一一激活它们来隔离问题。这导致了不一致的结果。这是一个测试的例子。第一次把“Ignore”注释去掉,就通过了。然后我取消了另一个测试的注释,但失败了。我把“忽略”注释放回去,第一次测试失败了,这让我很惊讶。提前感谢您的帮助。

class CitiUserPasswordValidatorSpec extends Specification{

@Shared def username = "username1";
@Shared def citiUserPasswordValidator = new ident.web.citi.CitiUserPasswordValidator()
private String invalidPassword;


@Ignore
def "Password is valid." (){
    setup:
        def facesContextMock = Mock(FacesContext)
        def uiComponentMock = Mock(UIComponent)
        def uiInputMock = Mock(UIInput)
        def uiViewRootMock = Mock(UIViewRoot)

        def password = "aBcqwe123"

        facesContextMock.getViewRoot() >> uiViewRootMock
        uiViewRootMock.findComponent("RtWindow:buttons:username") >> uiInputMock
        uiInputMock.getSubmittedValue() >> username
    when:
        citiUserPasswordValidator.validate(facesContextMock, uiComponentMock, password);
    then:
        notThrown ValidatorException
}...
4

0 回答 0