junit.framework.ComparisonFailure: expected:<..> but was:解决方法

junit.framework.ComparisonFailure: expected:<..> but was:解决方法

在使用dos窗口运行mvn指令:mvn clean test时出现一个错误:

[ERROR] Please refer to D:\霖儿的学习玩意儿\大三上学期\企业级应用构建与管理\实验\maven_demo\target\surefire-reports for the individual test results.

错误显示要从surefire-reports文件中寻找错误,查看surefire-reports文件:
junit.framework.ComparisonFailure: expected:<..> but was:解决方法
错误主体是这句:
junit.framework.ComparisonFailure: expected:<Hello [World]guoyilin!> but was:<Hello []guoyilin!>

在test文件中调用了assetEquals方法,该方法将括号中的语句与指定语句进行比对,若比对不相同则报错
junit.framework.ComparisonFailure: expected:<..> but was:解决方法
junit.framework.ComparisonFailure: expected:<..> but was:解决方法
可以看到,在sayHello方法中返回的语句与测试模块中指定的语句不同,错误就在这里,将语句修改至相同即可。