spockframework / spock

The Enterprise-ready testing and specification framework.
https://spockframework.org
Apache License 2.0
3.54k stars 467 forks source link

No junit failure description in ant 1.8 #269

Closed robfletcher closed 9 years ago

robfletcher commented 9 years ago

Originally reported on Google Code with ID 147

Currently 0.4 fails to output the reason for a failure when running ant 1.8 and junit
4.8 in classpath. The test will fail but the excellent description gets lost. Without
this spock cannot be used in organizations building with a current ant release. 

To reproduce follow the ant getting started documentation and introduce a failing assertion
(like replacing 5 with 55). 

With ANT_HOME set to 1.8.1 you get
 [junit] Testcase: can you figure out what I'm up to?(HelloSpock): FAILED
 [junit] null
 [junit] junit.framework.AssertionFailedError
 [junit]    at HelloSpock.can you figure out what I'm up to?(HelloSpock.groovy:6)

But with ANT_HOME set to 1.7.1 you get

   [junit] Testcase: can you figure out what I'm up to? took 0.17 sec
    [junit]     Caused an ERROR
    [junit] null
    [junit] Condition not satisfied:
    [junit] 
    [junit] name.size() == size
    [junit] |    |      |  |
    [junit] |    5      |  55
    [junit] Spock       false
    [junit] 
    [junit]     at HelloSpock.can you figure out what I'm up to?(HelloSpock.groovy:6)
    [junit] 
    [junit] Test HelloSpock FAILED

Following is on the classpath
$ ls lib
geb-core-0.4.jar        
groovy-all-1.7.2.jar        
maven-ant-tasks-2.1.1.jar   
spock-core-0.4-groovy-1.7.jar
geb-spock-0.4.jar       
junit-4.8.1.jar         
selenium-common-2.0a5.jar

A workaround is to use "-lib /usr/share/java/ant-1.7.1/lib/ant-junit.jar" argument
to ant (1.8) or otherwise downgrading the junit task to 1.7 - but that is likely to
cause other problems in the build. Another option may be a spock test-runner that discovers
specs and runs them and returns a error code for the number of failures.

Reported by peter.lundberg.se on 2010-11-25 11:54:48

robfletcher commented 9 years ago
0.5-SNAPSHOT fixes this problem, although the output now appears twice. I'll see if
I can do something about that.

Reported by pniederw on 2010-11-25 12:47:40

robfletcher commented 9 years ago
With Ant 1.8.1 and Spock 0.5-SNAPSHOT, I'm getting the exact same output for specs as
for JUnit tests. It's unfortunate that Ant prints exception output twice (once getMessage(),
once toString()), but again the same problem exists for JUnit tests. Here is how I
have configured the Ant JUnit task: http://code.google.com/p/spock/source/browse/branches/groovy-1.7/spock-example/build.xml

If you are still experiencing problems, please raise a new issue.

Reported by pniederw on 2010-12-09 00:01:14

robfletcher commented 9 years ago
Great thank you!
What are the plans for 0.5? Given the usability and stability of spock I would consider
bumping to 1.0 to ease spreading and acceptance in conservative organizations.

Reported by peter.lundberg.se on 2010-12-09 07:51:06

robfletcher commented 9 years ago
Release of 0.5 is imminent. I agree that going 1.0 is important, but I won't make any
promises.

Reported by pniederw on 2010-12-09 12:06:14