git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@691622 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -258,4 +258,20 @@ | |||||
| </echo> | </echo> | ||||
| </target> | </target> | ||||
| <!-- Bugzilla Issue 45411 --> | |||||
| <target name="testMultilineAssertsNoFork"> | |||||
| <junit> | |||||
| <test name="org.example.junit.MultilineAsserts"/> | |||||
| <classpath refid="test"/> | |||||
| </junit> | |||||
| </target> | |||||
| <!-- Bugzilla Issue 45411 --> | |||||
| <target name="testMultilineAssertsFork"> | |||||
| <junit fork="true"> | |||||
| <test name="org.example.junit.MultilineAsserts"/> | |||||
| <classpath refid="test"/> | |||||
| </junit> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -115,6 +115,16 @@ public abstract class BuildFileTest extends TestCase { | |||||
| realLog.indexOf(substring) >= 0); | realLog.indexOf(substring) >= 0); | ||||
| } | } | ||||
| /** | |||||
| * Assert that the given substring is not in the log messages. | |||||
| */ | |||||
| public void assertLogNotContaining(String substring) { | |||||
| String realLog = getLog(); | |||||
| assertFalse("didn't expect log to contain \"" + substring + "\" log was \"" | |||||
| + realLog + "\"", | |||||
| realLog.indexOf(substring) >= 0); | |||||
| } | |||||
| /** | /** | ||||
| * Assert that the given substring is in the output messages. | * Assert that the given substring is in the output messages. | ||||
| * @since Ant1.7 | * @since Ant1.7 | ||||
| @@ -160,6 +170,15 @@ public abstract class BuildFileTest extends TestCase { | |||||
| assertLogContaining(log); | assertLogContaining(log); | ||||
| } | } | ||||
| /** | |||||
| * Assert that the given message has not been logged with a | |||||
| * priority <= INFO when running the given target. | |||||
| */ | |||||
| public void expectLogNotContaining(String target, String log) { | |||||
| executeTarget(target); | |||||
| assertLogNotContaining(log); | |||||
| } | |||||
| /** | /** | ||||
| * Gets the log the BuildFileTest object. | * Gets the log the BuildFileTest object. | ||||
| * Only valid if configureProject() has been called. | * Only valid if configureProject() has been called. | ||||
| @@ -216,11 +216,22 @@ public class JUnitTaskTest extends BuildFileTest { | |||||
| } | } | ||||
| } | } | ||||
| public void testBatchTestForkOnceCustomFormatter() { | public void testBatchTestForkOnceCustomFormatter() { | ||||
| assertResultFilesExist("testBatchTestForkOnceCustomFormatter", "foo"); | assertResultFilesExist("testBatchTestForkOnceCustomFormatter", "foo"); | ||||
| } | } | ||||
| // Bugzilla Issue 45411 | |||||
| public void testMultilineAssertsNoFork() { | |||||
| expectLogNotContaining("testMultilineAssertsNoFork", "messed up)"); | |||||
| assertLogNotContaining("crashed)"); | |||||
| } | |||||
| // Bugzilla Issue 45411 | |||||
| public void XtestMultilineAssertsFork() { | |||||
| expectLogNotContaining("testMultilineAssertsFork", "messed up)"); | |||||
| assertLogNotContaining("crashed)"); | |||||
| } | |||||
| private void assertResultFilesExist(String target, String extension) { | private void assertResultFilesExist(String target, String extension) { | ||||
| executeTarget(target); | executeTarget(target); | ||||
| assertResultFileExists("JUnitClassLoader", extension); | assertResultFileExists("JUnitClassLoader", extension); | ||||
| @@ -0,0 +1,27 @@ | |||||
| /* | |||||
| * Licensed to the Apache Software Foundation (ASF) under one or more | |||||
| * contributor license agreements. See the NOTICE file distributed with | |||||
| * this work for additional information regarding copyright ownership. | |||||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
| * (the "License"); you may not use this file except in compliance with | |||||
| * the License. You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| * | |||||
| */ | |||||
| package org.example.junit; | |||||
| import junit.framework.TestCase; | |||||
| public class MultilineAsserts extends TestCase { | |||||
| public void testFoo() { assertTrue("testFoo \nmessed up", false); } | |||||
| public void testBar() { assertTrue("testBar \ndidn't work", true); } | |||||
| public void testFee() { assertTrue("testFee \ncrashed", false); } | |||||
| public void testFie() { assertTrue("testFie \nbroke", true); } | |||||
| } | |||||