以下是執(zhí)行的步驟:第 1 步: 基于此,我構(gòu)建了一個獨立的 jar,其中包含使用maven-shade-plugin.pom.xml<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <configuration> <testFailureIgnore>true</testFailureIgnore> <testSourceDirectory>${basedir}/src/main/java/</testSourceDirectory> <testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory> <reportsDirectory>${project.build.directory}/test-output/${timestamp}</reportsDirectory> </configuration> </plugin> <!-- https://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <!-- https://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html --> <shadedArtifactAttached>true</shadedArtifactAttached> <shadedClassifierName>standalone</shadedClassifierName> <transformers> <!-- https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html --> <mainClass>runners.RunCukesTest</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins></build>將該main()方法添加到 runner 類中,并根據(jù)this、this和this傳遞 cmdline 參數(shù)。
1 回答

蠱毒傳說
TA貢獻1895條經(jīng)驗 獲得超3個贊
您傳遞了 Cucumber 的相對路徑src\main\resources\features
。因為您正在執(zhí)行 Jar,所以該相對路徑將使用當(dāng)前工作目錄轉(zhuǎn)換為絕對路徑。但是,因為src\main\resources\features
是您的功能的源文件夾,所以找不到任何內(nèi)容,您會得到:
線程“main”中的異常 java.lang.IllegalArgumentException:不是文件或目錄:\path\to\jar\src\main\resources\features
相反,您必須告訴 Cucumber 您的功能位于類路徑上。您可以通過以下方式執(zhí)行此操作:
"classpath:features"
添加回答
舉報
0/150
提交
取消