Spring Restdocs source gradle build fails during test

时间:2016-07-11 20:55:29

标签: spring-restdocs

I have downloaded a copy of the 1.1.0-RELEASE tagged source code for Spring RESTdocs, but "gradlew build" is failing during the test phase. 273 of 502 tests are failing with variations on this error: org.springframework.restdocs.request.RequestPartsSnippetTests > requestPartsWithOptionalColumn[Markdown] FAILED java.lang.AssertionError: Expected: is adoc snippetPart | Optional | Description ---- | -------- | ----------- a | true | one b | false | two but: was:Part | Optional | Description ---- | -------- | ----------- a | true | one b | false | two

The problem looks to be that the string "adoc snippet" is prefixed to the start of the expected output. I don't think that's right, although I can see in the AbstractContentSnippetMatcher.describeTo() why it's happening and it doesn't look very conditional so maybe it's the test's actual result that's wrong?

I have made no changes to the source code* but I don't see other people reporting this problem, so I'm mystified. I'm entirely new to gradle. Is there some kind of config I need to set up to make the tests pass? Should I be using a different target?

(OK... 1 teensy change: I removed the new-line-at-end-of-file check from the checkStyle - I'm downloading from Github onto a Windows PC.)

1 个答案:

答案 0 :(得分:0)

问题是zip中的文件具有Unix样式的行结尾,但是在Windows上运行时,Checkstyle和测试需要Windows样式的行结尾。

通常,Windows Git客户端会在您签出代码时通过转换行结尾来为您解决此问题。例如,Git for Windows的默认配置是使用Windows样式的行结尾检查代码,但使用Windows样式的行结尾提交更改。

您可以找到一个Windows实用程序,它会将行结尾从LF批量转换为CRLF。如果做不到这一点,最简单的方法是安装一个Git客户端(例如我上面链接的Git for Windows),确保它配置为执行行结束转换,然后:

> git clone https://github.com/spring-projects/spring-restdocs
> cd spring-restdocs
> gradlew build