add suiteSetUp and suiteTearDown targets, submitted by David jackman, PR: 43475
git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/antunit/trunk@645886 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cc4c0a9083
commit
0d488d0faf
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="suitesetup-and-suiteteardown"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<fail message="outputfile property is not set." unless="outputfile" />
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
<fail message="Expected error" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
<fail message="Expected error" />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
<fail message="Expected error" />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
<fail message="Expected error" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<fail message="outputfile property is not set." unless="outputfile" />
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
<fail message="Expected failure" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
<au:assertPropertySet name="bogus" message="Expected failure" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
<au:assertPropertySet name="bogus" message="Expected failure" />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
<au:assertPropertySet name="bogus" message="Expected failure" />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="failed-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="setUp">
|
||||
<echo file="${outputfile}" append="true" message="S" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="tearDown">
|
||||
<echo file="${outputfile}" append="true" message="T" />
|
||||
<au:assertPropertySet name="bogus" message="Expected failure" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="no-setup"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteTearDown">
|
||||
<echo file="${outputfile}" append="true" message="B" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="no-teardown"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<fail message="These are not standalone tests." />
|
||||
</target>
|
||||
|
||||
<target name="suiteSetUp">
|
||||
<echo file="${outputfile}" append="true" message="A" />
|
||||
</target>
|
||||
|
||||
<target name="test1">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test2">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test3">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
<target name="test4">
|
||||
<echo file="${outputfile}" append="true" message="E" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,119 +1,281 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="setupandteardown-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<target name="all">
|
||||
<au:antunit>
|
||||
<file file="${ant.file}" />
|
||||
<au:plainlistener/>
|
||||
</au:antunit>
|
||||
</target>
|
||||
|
||||
<!-- Verifies that both setup and teardown are called for each test -->
|
||||
<target name="testBoth">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/both.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SETSETSETSET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests no setup -->
|
||||
<target name="testNoSetup">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/nosetup.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ETETETET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests no teardown -->
|
||||
<target name="testNoTeardown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/noteardown.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SESESESE" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Verifies teardown is called for a failed test -->
|
||||
<target name="testFailedTest">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failedtest.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a failure in setup -->
|
||||
<target name="testFailedSetup">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failedsetup.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ST" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a failure in teardown -->
|
||||
<target name="testFailedTeardown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failedteardown.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<project name="setupandteardown-test"
|
||||
default="all"
|
||||
xmlns:au="antlib:org.apache.ant.antunit">
|
||||
|
||||
<typedef name="reportlistener"
|
||||
classname="org.apache.ant.antunit.SetUpAndTearDownTest$TestReportListener"/>
|
||||
|
||||
<target name="all">
|
||||
<au:antunit>
|
||||
<file file="${ant.file}" />
|
||||
<au:plainlistener/>
|
||||
</au:antunit>
|
||||
</target>
|
||||
|
||||
<!-- Verifies that both setup and teardown are called for each test -->
|
||||
<target name="testBoth">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/both.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SETSETSETSET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests no setup -->
|
||||
<target name="testNoSetup">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/nosetup.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ETETETET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests no teardown -->
|
||||
<target name="testNoTeardown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/noteardown.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SESESESE" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Verifies teardown is called for a failed test -->
|
||||
<target name="testFailedTest">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failedtest.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a failure in setup -->
|
||||
<target name="testFailureSetup">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failuresetup.xml" />
|
||||
<au:plainlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="STSTST" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests an error in setup -->
|
||||
<target name="testErrorSetup">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/errorsetup.xml" />
|
||||
<au:plainlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="STSTST" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a failure in teardown -->
|
||||
<target name="testFailureTeardown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failureteardown.xml" />
|
||||
<au:plainlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SETSETSET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a error in teardown -->
|
||||
<target name="testErrorTeardown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/errorteardown.xml" />
|
||||
<au:plainlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="SETSETSET" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Verifies that both suiteSetUp and suiteTearDown are called for the whole test script -->
|
||||
<target name="testBothSuite">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/bothsuite.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ASETSETSETSETB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests no suiteSetUp -->
|
||||
<target name="testNoSuiteSetUp">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/nosuitesetup.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="EEEEB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests no suiteTearDown -->
|
||||
<target name="testNoSuiteTearDown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit>
|
||||
<file file="antunit/setupandteardown/nosuiteteardown.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="AEEEE" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Verifies suite teardown is called for a failed test -->
|
||||
<target name="testFailedTestSuite">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failedtestsuite.xml" />
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ASETB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a failure in suiteSetUp -->
|
||||
<target name="testFailureSuiteSetUp">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failuresuitesetup.xml" />
|
||||
<au:plainlistener/>
|
||||
<reportlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="AB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests an error in suiteSetUp -->
|
||||
<target name="testErrorSuiteSetUp">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/errorsuitesetup.xml" />
|
||||
<au:plainlistener/>
|
||||
<reportlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="AB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests a failure in suiteTearDown -->
|
||||
<target name="testFailureSuiteTearDown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/failuresuiteteardown.xml" />
|
||||
<au:plainlistener/>
|
||||
<reportlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ASETSETSETSETB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
<!-- Tests an error in suiteTearDown -->
|
||||
<target name="testErrorSuiteTearDown">
|
||||
<tempfile property="outputfile" deleteonexit="true" />
|
||||
<au:antunit failOnError="false" errorProperty="failure">
|
||||
<file file="antunit/setupandteardown/errorsuiteteardown.xml" />
|
||||
<au:plainlistener/>
|
||||
<reportlistener/>
|
||||
<propertyset>
|
||||
<propertyref name="outputfile" />
|
||||
</propertyset>
|
||||
</au:antunit>
|
||||
<fail unless="failure" message="Test should have failed." />
|
||||
<au:assertFileExists file="${outputfile}" message="Output file doesn't exist" />
|
||||
<loadfile property="output" srcFile="${outputfile}" />
|
||||
<au:assertEquals expected="ASETSETSETSETB" actual="${output}" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -82,6 +82,16 @@ public class AntUnit extends Task {
|
|||
* name of the magic tearDown target.
|
||||
*/
|
||||
private static final String TEARDOWN = "tearDown";
|
||||
|
||||
/**
|
||||
* name of the magic suiteSetUp target.
|
||||
*/
|
||||
private static final String SUITESETUP = "suiteSetUp";
|
||||
|
||||
/**
|
||||
* name of the magic suiteTearDown target.
|
||||
*/
|
||||
private static final String SUITETEARDOWN = "suiteTearDown";
|
||||
|
||||
/**
|
||||
* The build files to process.
|
||||
|
|
@ -224,12 +234,47 @@ public class AntUnit extends Task {
|
|||
Map targets = newProject.getTargets();
|
||||
boolean setUp = targets.containsKey(SETUP);
|
||||
boolean tearDown = targets.containsKey(TEARDOWN);
|
||||
boolean suiteSetUp = targets.containsKey(SUITESETUP);
|
||||
boolean suiteTearDown = targets.containsKey(SUITETEARDOWN);
|
||||
|
||||
// start test
|
||||
newProject.fireBuildStarted();
|
||||
|
||||
Throwable caught = null;
|
||||
try {
|
||||
if (suiteSetUp) {
|
||||
boolean success = false;
|
||||
try {
|
||||
newProject.executeTarget(SUITESETUP);
|
||||
success = true;
|
||||
} catch (AssertionFailedException e) {
|
||||
fireStartTest(SUITESETUP);
|
||||
fireFail(SUITESETUP, e);
|
||||
} catch (BuildException e) {
|
||||
boolean failed = false;
|
||||
fireStartTest(SUITESETUP);
|
||||
|
||||
// try to see whether the BuildException masks
|
||||
// an AssertionFailedException. If so, treat
|
||||
// it as failure instead of error.
|
||||
Throwable t = e.getCause();
|
||||
while (t != null && t instanceof BuildException) {
|
||||
if (t instanceof AssertionFailedException) {
|
||||
failed = true;
|
||||
fireFail(SUITESETUP, (AssertionFailedException) t);
|
||||
break;
|
||||
}
|
||||
t = ((BuildException) t).getCause();
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
fireError(SUITESETUP, e);
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Iterator iter = targets.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String name = (String) iter.next();
|
||||
|
|
@ -308,6 +353,35 @@ public class AntUnit extends Task {
|
|||
} catch (Throwable e) {
|
||||
caught = e;
|
||||
} finally {
|
||||
if (suiteTearDown) {
|
||||
try {
|
||||
newProject.executeTarget(SUITETEARDOWN);
|
||||
} catch (AssertionFailedException e) {
|
||||
fireStartTest(SUITETEARDOWN);
|
||||
fireFail(SUITETEARDOWN, e);
|
||||
} catch (BuildException e) {
|
||||
boolean failed = false;
|
||||
fireStartTest(SUITETEARDOWN);
|
||||
|
||||
// try to see whether the BuildException masks
|
||||
// an AssertionFailedException. If so, treat
|
||||
// it as failure instead of error.
|
||||
Throwable t = e.getCause();
|
||||
while (t != null && t instanceof BuildException) {
|
||||
if (t instanceof AssertionFailedException) {
|
||||
failed = true;
|
||||
fireFail(SUITETEARDOWN, (AssertionFailedException) t);
|
||||
break;
|
||||
}
|
||||
t = ((BuildException) t).getCause();
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
fireError(SUITETEARDOWN, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newProject.fireBuildFinished(caught);
|
||||
newProject = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,59 +1,202 @@
|
|||
/*
|
||||
* 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.apache.ant.antunit;
|
||||
|
||||
import org.apache.tools.ant.BuildFileTest;
|
||||
|
||||
public class SetUpAndTearDownTest extends BuildFileTest {
|
||||
|
||||
public SetUpAndTearDownTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
configureProject("src/etc/testcases/setupandteardown.xml");
|
||||
}
|
||||
|
||||
|
||||
public void testBoth() {
|
||||
executeTarget("testBoth");
|
||||
}
|
||||
|
||||
public void testNoSetup() {
|
||||
executeTarget("testNoSetup");
|
||||
}
|
||||
|
||||
public void testNoTeardown() {
|
||||
executeTarget("testNoTeardown");
|
||||
}
|
||||
|
||||
public void testFailedTest() {
|
||||
executeTarget("testFailedTest");
|
||||
}
|
||||
|
||||
public void testFailedSetup() {
|
||||
executeTarget("testFailedSetup");
|
||||
}
|
||||
|
||||
public void testFailedTeardown() {
|
||||
executeTarget("testFailedTeardown");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.apache.ant.antunit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.apache.ant.antunit.listener.BaseAntUnitListener;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.BuildFileTest;
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
public class SetUpAndTearDownTest extends BuildFileTest {
|
||||
|
||||
public static class TestReportListener extends BaseAntUnitListener {
|
||||
|
||||
private OutputStream out = null;
|
||||
/**
|
||||
* Helper to store intermediate output.
|
||||
*/
|
||||
private StringWriter inner;
|
||||
/**
|
||||
* Convenience layer on top of {@link #inner inner}.
|
||||
*/
|
||||
private PrintWriter wri;
|
||||
|
||||
public TestReportListener() {
|
||||
super(new BaseAntUnitListener.SendLogTo(SendLogTo.ANT_LOG), "txt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Where to send the test report.
|
||||
*/
|
||||
public void setSendLogTo(BaseAntUnitListener.SendLogTo logTo) {
|
||||
super.setSendLogTo(logTo);
|
||||
}
|
||||
|
||||
public void startTestSuite(Project testProject, String buildFile) {
|
||||
super.startTestSuite(testProject, buildFile);
|
||||
inner = new StringWriter();
|
||||
wri = new PrintWriter(inner);
|
||||
out = getOut(buildFile);
|
||||
}
|
||||
|
||||
public void endTestSuite(Project testProject, String buildFile) {
|
||||
if (out != null) {
|
||||
try {
|
||||
wri.close();
|
||||
out.write(inner.toString().getBytes());
|
||||
out.flush();
|
||||
} catch (IOException ioex) {
|
||||
throw new BuildException("Unable to write output", ioex);
|
||||
} finally {
|
||||
close(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endTest(String target) {
|
||||
}
|
||||
|
||||
public void addFailure(String target, AssertionFailedException ae) {
|
||||
super.addFailure(target, ae);
|
||||
wri.println("failure:" + target + "(" + ae.getMessage() + ")");
|
||||
}
|
||||
|
||||
public void addError(String target, Throwable ae) {
|
||||
super.addError(target, ae);
|
||||
wri.println("error:" + target + "(" + ae.getMessage() + ")");
|
||||
}
|
||||
|
||||
public void messageLogged(int level, String message) {}
|
||||
}
|
||||
|
||||
public SetUpAndTearDownTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
configureProject("src/etc/testcases/setupandteardown.xml");
|
||||
}
|
||||
|
||||
|
||||
public void testBoth() {
|
||||
executeTarget("testBoth");
|
||||
}
|
||||
|
||||
public void testNoSetup() {
|
||||
executeTarget("testNoSetup");
|
||||
}
|
||||
|
||||
public void testNoTeardown() {
|
||||
executeTarget("testNoTeardown");
|
||||
}
|
||||
|
||||
public void testFailedTest() {
|
||||
executeTarget("testFailedTest");
|
||||
System.out.println(getLog());
|
||||
}
|
||||
|
||||
public void testFailureSetup() {
|
||||
executeTarget("testFailureSetup");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 3, Failures: 3, Errors: 0,");
|
||||
assertTrue("summary", index > -1);
|
||||
}
|
||||
|
||||
public void testErrorSetup() {
|
||||
executeTarget("testErrorSetup");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 3, Failures: 0, Errors: 3,");
|
||||
assertTrue("summary", index > -1);
|
||||
}
|
||||
|
||||
public void testFailureTeardown() {
|
||||
executeTarget("testFailureTeardown");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 3, Failures: 3, Errors: 0,");
|
||||
assertTrue("summary", index > -1);
|
||||
}
|
||||
|
||||
public void testErrorTeardown() {
|
||||
executeTarget("testErrorTeardown");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 3, Failures: 0, Errors: 3,");
|
||||
assertTrue("summary", index > -1);
|
||||
}
|
||||
|
||||
public void testBothSuite() {
|
||||
executeTarget("testBothSuite");
|
||||
}
|
||||
|
||||
public void testNoSuiteSetup() {
|
||||
executeTarget("testNoSuiteSetUp");
|
||||
}
|
||||
|
||||
public void testNoSuiteTeardown() {
|
||||
executeTarget("testNoSuiteTearDown");
|
||||
}
|
||||
|
||||
public void testFailedTestSuite() {
|
||||
executeTarget("testFailedTestSuite");
|
||||
System.out.println(getLog());
|
||||
}
|
||||
|
||||
public void testFailureSuiteSetUp() {
|
||||
executeTarget("testFailureSuiteSetUp");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 1, Failures: 1, Errors: 0,");
|
||||
assertTrue("summary", index > -1);
|
||||
index = log.indexOf("failure:suiteSetUp(Expected failure)");
|
||||
assertTrue("testname", index > -1);
|
||||
}
|
||||
|
||||
public void testErrorSuiteSetUp() {
|
||||
executeTarget("testErrorSuiteSetUp");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 1, Failures: 0, Errors: 1,");
|
||||
assertTrue("summary", index > -1);
|
||||
index = log.indexOf("error:suiteSetUp(Expected error)");
|
||||
assertTrue("testname", index > -1);
|
||||
}
|
||||
|
||||
public void testFailureSuiteTearDown() {
|
||||
executeTarget("testFailureSuiteTearDown");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 5, Failures: 1, Errors: 0,");
|
||||
assertTrue("summary", index > -1);
|
||||
index = log.indexOf("failure:suiteTearDown(Expected failure)");
|
||||
assertTrue("testname", index > -1);
|
||||
}
|
||||
|
||||
public void testErrorSuiteTearDown() {
|
||||
executeTarget("testErrorSuiteTearDown");
|
||||
String log = getLog();
|
||||
int index = log.indexOf("Tests run: 5, Failures: 0, Errors: 1,");
|
||||
assertTrue("summary", index > -1);
|
||||
index = log.indexOf("error:suiteTearDown(Expected error)");
|
||||
assertTrue("testname", index > -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
2
src/tests/junit/org/apache/ant/antunit/listener/PlainListenerTest.java
Executable file → Normal file
2
src/tests/junit/org/apache/ant/antunit/listener/PlainListenerTest.java
Executable file → Normal file
|
|
@ -131,7 +131,6 @@ public class PlainListenerTest extends BuildFileTest {
|
|||
assertTrue("Second tearDown not present", index > -1);
|
||||
}
|
||||
|
||||
/*
|
||||
public void testSuiteSetUpTearDown() {
|
||||
executeTarget("showinfo");
|
||||
String log = getLog();
|
||||
|
|
@ -144,5 +143,4 @@ public class PlainListenerTest extends BuildFileTest {
|
|||
index = log.indexOf("suiteTearDown", index + 1);
|
||||
assertTrue("suiteTearDown present more than once", index == -1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
2
src/tests/junit/org/apache/ant/antunit/listener/XMLListenerTest.java
Executable file → Normal file
2
src/tests/junit/org/apache/ant/antunit/listener/XMLListenerTest.java
Executable file → Normal file
|
|
@ -66,11 +66,9 @@ public class XMLListenerTest extends BuildFileTest {
|
|||
executeTarget("setupteardown");
|
||||
}
|
||||
|
||||
/*
|
||||
public void testSuiteSetUpTearDown() {
|
||||
executeTarget("suitesetupteardown");
|
||||
}
|
||||
*/
|
||||
|
||||
public void testBadCharacters() {
|
||||
executeTarget("badcharacters");
|
||||
|
|
|
|||
Loading…
Reference in New Issue