ビルドで一緒に実行すると、「permgen スペース」が原因で失敗する 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>
テスト クラス内のすべてのテストを無視し、それらを 1 つずつアクティブにすることで、問題を切り分けようとしました。これにより、一貫性のない結果が得られました。以下は、1 つのテストの例です。「無視」アノテーションを初めて外したときは、合格しました。次に、失敗した別のテストの注釈を外しました。「無視」アノテーションを元に戻したところ、最初のテストが失敗し、驚きました。助けてくれてありがとう。
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
}...