为了账号安全,请及时绑定邮箱和手机立即绑定

各位大哥!啥问题?maven编译问题

Running com.imooc.maven01.model.HelloWorldTest

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.103 sec <<< FAILURE!

testHello(com.imooc.maven01.model.HelloWorldTest)  Time elapsed: 0.014 sec  <<< FAILURE!

org.junit.ComparisonFailure: expected:<Hello World[!]> but was:<Hello World[]>

        at org.junit.Assert.assertEquals(Assert.java:125)

        at org.junit.Assert.assertEquals(Assert.java:147)

        at com.imooc.maven01.model.HelloWorldTest.testHello(HelloWorldTest.java:9)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:498)

        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)

        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)

        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:498)

        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)

        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)

        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)

        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)


正在回答

2 回答

我也遇到了,你HelloWord类里返回的结果和Test不一样,最好复制粘贴

0 回复 有任何疑惑可以回复我~

expected:<Hello World[!]> but was:<Hello World[]>,这个就是assert里面的校验方法,就是实际结果少了一个“!”,你可以检查一下之前那个项目里的返回结果的实际值是什么

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
项目管理利器——maven
  • 参与学习       173090    人
  • 解答问题       742    个

使用maven来构建和管理Java项目,从环境配置,到maven核心知识

进入课程

各位大哥!啥问题?maven编译问题

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信