我了解Groovy的基础知识,现在遇到了非常奇怪的问题。 任何指针都将真正有用。在我的项目之前,我使用的是黄瓜库克-1.25,具有以下依赖性。
groovy-all - 1.8.7
junit - 4.11
gmaven - 1.3
cucumber-jvm-deps -1.0.3
cucumber-groovy (info.cukes) - 1.1.2
cucumber-junit(info.cukes) - 1.1.2
cucumber-reporting(info.cukes) - 0.0.21
现在,我想升级到Cucumber 5,并修改了以下依赖性:
groovy-all - 2.4.12
junit - 4.13
gmaven - 1.3
cucumber-jvm-deps(io.cucumber) -1.0.6
cucumber-groovy (io.cucumber) - 5.1.3
cucumber-junit(io.cucumber) - 5.1.3
cucumber-reporting(io.cucumber) - 0.0.21
cucumber-core(io.cucumber) - 5.1.3
gherkin - 5.1.3
extentreports-cucumber5-adapter - 1.3.2 (This has transient dependency of Cucumber-core & Cucumber-java)
freemarker - 2.3.29
mongodb-driver - 3.3.0
我修改了步骤定义,并试图运行我的功能,但看到以下异常。另外,我可以通过Intellij中的运行程序运行它。不知道这是一些依赖问题还是我错过了什么。
mvn clean test -B -f C:/Tetris/app-test/integration/pom.xml -s C:/Tetris/modules/G3/Maven/integration.xml -DfailIfNoTests=false -Dmaven.test.failure.ignore -Pcucumber4 -DenvHost=myhost -DenvDomain=apac.sas.com -DbuildDirectory=target\Cucumber-dailyrun -Dtest=TestRunner
groovy.lang.MissingPropertyException: No such property: SANDBOX_DB_OPER2 for class: com.myproj.tetris.cucumber.stepdefinition.g3.monitor.reports.ScheduledReportAfterBDEE2E
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:310)
at com.myproj.tetris.cucumber.stepdefinition.g3.monitor.reports.ScheduledReportAfterBDEE2E.clearScheduledReportEntries(ScheduledReportAfterBDEE2E.groovy:151)
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:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:352)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:161)
at com.myproj.tetris.cucumber.stepdefinition.g3.monitor.reports.ScheduledReportAfterBDEE2E$_run_closure4.doCall(ScheduledReportAfterBDEE2E.groovy:60)
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:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at io.cucumber.groovy.Invoker.invoke(Invoker.java:19)
at io.cucumber.groovy.GroovyStepDefinition.execute(GroovyStepDefinition.java:27)
at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63)
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:64)
at io.cucumber.core.runner.TestStep.run(TestStep.java:49)
at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:46)
at io.cucumber.core.runner.TestCase.run(TestCase.java:51)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:66)
at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:149)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:83)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:24)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at io.cucumber.junit.Cucumber.runChild(Cucumber.java:185)
at io.cucumber.junit.Cucumber.runChild(Cucumber.java:83)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at io.cucumber.junit.Cucumber$RunCucumber.evaluate(Cucumber.java:219)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junitcore.JUnitCore.run(JUnitCore.java:55)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:137)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:107)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:83)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:75)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:161)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
分析以上堆栈后抛出此错误的代码。方法“ clearScheduledReportEntries”的第一行中的变量SANDBOX_DB_OPER2引发此错误。
package com.myproj.cucumber.stepdefinition.g3.monitor.reports
import com.g3.client.rest.RestServiceUtil
import com.g3.client.rest.TetrisRESTClient
import com.tetris.util.DbConnection
import com.tetris.util.PropertiesTestHelper
import com.tetris.util.opera.OperaGlobalFunctions
import com.tetris.util.propertyrollout.PropertyRolloutRESTUtil
import com.tetris.util.propertyrollout.PropertyRolloutTestHelper
import common.JemsTest
import common.OperaUtil
import groovy.transform.Field
import io.cucumber.datatable.DataTable
import io.cucumber.groovy.EN
import io.cucumber.groovy.Hooks
import org.apache.commons.codec.binary.Base64
@Field String SANDBOX_DB_OPER2 = '011022'
@Field String SANDBOX_PROPERTY_ID = '11022'
String TRUE = "TRUE"
String FALSE = "FALSE"
String context = 'pacman.SandBox.OPER2'
String DE_SCHEDULED_REPORT_POST_BDE = 'pacman.PreProduction.DataExtractionScheduledReportsPostBDE';
String PICKUP_CHANGE_SCHEDULED_REPORT_POST_BDE = 'pacman.PreProduction.PickUpChangeScheduledReportsPostBDE';
String BOOKING_SITUATION_SCHEDULED_REPORT_POST_BDE = 'pacman.PreProduction.BookingSituationScheduledReportsPostBDE';
String RATE_PLAN_PROD_SCHEDULED_REPORT_POST_BDE = 'pacman.PreProduction.RatePlanProductionScheduledReportsPostBDE';
@Field TetrisRESTClient tetrisRESTClient
@Field TetrisRESTClient jobRestClient
connection = DbConnection.getTenantDatabaseConnection(SANDBOX_DB_OPER2);
this.metaClass.mixin(Hooks)
this.metaClass.mixin(EN)
//Step Definitions
And(/Clear all Scheduled Reports related data for OPER2/) { ->
clearScheduledReportEntries()
}
///Private Methods
void clearScheduledReportEntries() {
def connectionOPER2 = DbConnection.getTenantDatabaseConnection(SANDBOX_DB_OPER2)
connectionOPER2.execute("delete from ScheduledReport_Delivery_Audit");
connectionOPER2.execute("delete from ScheduledReports");
connectionOPER2.close();
}