黄瓜验收测试表失败

时间:2016-03-29 15:21:52

标签: gradle cucumber

当我进行gradle测试时,我在以下场景中出错。我在下面列出了堆栈跟踪。

@Domain
    @NotImplemented
    Scenario Outline: Generating longitude and latitude of a property
     Given I am a Landlord "John"
     And I have entered the address <ADDRESS>
     And I have entered the postcode <POSTCODE>
     When I submit the form
     Then the property should be listed on the system
     And with the postcode <POSTCODE>
     And should generate the latitude <LATITUDES>
     And longitude <LONGITUDES>



    Examples:
          |ADDRESS            |POSTCODE  |LATITUDES   |LONGITUDES   |
          |"60 Lancaster Road |"LE1 7HA" |"52.6257172"|"1.12760520" |
          |"17 Fleet Street"  |"HP20 2PA"|"51.8204651"|"-0.8132931" |
          |"300 Welford Road" |"LE2 6EG" |"52.6143175"|"-1.1248989" |

Stacktrace

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':test'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:62)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
        at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:155)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:152)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:100)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:94)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:94)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.GradleException: Could not generate test report to 'C:\Users\Majid\Desktop\Github-Projects\Merge\co2015-group-06-repo\springMvc\build\reports\tests'.
        at org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport.generateFiles(DefaultTestReport.java:90)
        at org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport.generateReport(DefaultTestReport.java:45)
        at org.gradle.api.tasks.testing.Test.executeTests(Test.java:558)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 57 more
Caused by: org.gradle.api.UncheckedIOException: Could not write to file 'C:\Users\Majid\Desktop\Github-Projects\Merge\co2015-group-06-repo\springMvc\build\reports\tests\packages\| "17 Fleet Street" | "HP20 2PA" | "51.8204651" | "-0.html'.
        at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:115)
        at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:91)
        at org.gradle.internal.IoActions.writeTextFile(IoActions.java:38)
        at org.gradle.reporting.HtmlReportRenderer$DefaultHtmlReportContext.renderHtmlPage(HtmlReportRenderer.java:117)
        at org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport$2.render(DefaultTestReport.java:82)
        at org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport$2.render(DefaultTestReport.java:74)
        at org.gradle.reporting.HtmlReportRenderer.render(HtmlReportRenderer.java:42)
        at org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport.generateFiles(DefaultTestReport.java:74)
        ... 67 more
Caused by: java.io.FileNotFoundException: C:\Users\Majid\Desktop\Github-Projects\Merge\co2015-group-06-repo\springMvc\build\reports\tests\packages\| "17 Fleet Street" | "HP20 2PA" | "51.8204651" | "-0.html (The filename, directory name, or volume label syntax is incorrect)
        at org.gradle.internal.IoActions$TextFileWriterIoAction.execute(IoActions.java:108)
        ... 74 more

我认为它是因为它无法处理多头和负数。但是我删除了引号但是仍然出现了同样的错误。

2 个答案:

答案 0 :(得分:2)

Gradle因为无法写入文件而感到沮丧。文件名是从方案名称生成的。您的方案名称是根据大纲中的参数构建的。在这种情况下,“17 Fleet Street”“HP20 2PA”“51.8204651”“ - 0.8132931”。Gradle试图写入的文件名是:

C:\Users\Majid\Desktop\Github-Projects\Merge\co2015-group-06-repo\springMvc\build\reports\tests\packages\| "17 Fleet Street" | "HP20 2PA" | "51.8204651" | "-0.html (The filename, directory name, or volume label syntax is incorrect)

Windows文件的奇怪文件名。

您的问题是Windows对文件名和Cucumber有意见的组合,尝试根据场景大纲中的行的参数构建文件名。

观察您的场景,我将从简化它开始。我没有看到你的三行有什么特别之处,其中两行看起来像是重复我。因此,我不会使用场景大纲,而是使用常规场景,至少从开始。如果需要,那么我可能会介绍一个场景大纲。但有可能我不会,而是有两个场景,他们的名字将表明它是什么,我特意试图验证该场景。

请记住,场景大纲只是许多场景的语法糖。

有关情景大纲的更多信息,请访问https://github.com/cucumber/cucumber/wiki/Scenario-Outlines

答案 1 :(得分:2)

正如@ thomas-sundberg建议的(正如你已经发现的那样),Windows balks at certain filename characters黄瓜在其中使用了它的测试名称。

幸运的是,这只发生在gradle的test任务正在编写Html DirectoryReport测试输出报告时。您可以在build.gradle

中设置以下内容将其关闭
// turn off html reports... windows can't handle certain cucumber test name characters.
test.reports.getHtml().enabled = false
不用担心,gradle仍会运行您的测试,仍会写出JUnitXmlReport报告!