我正在尝试为Cucumber的Java8方言设置一个示例项目。我的问题是,我没有让它运行。我总是得到以下异常层次结构:
Using built-in stream user interface
-> Detected 8 CPUs online; setting concurrency level to 8.
-> License accepted by command line option.
-> Installing NVIDIA driver version 352.39.
-> There appears to already be a driver installed on your system (version: 352.39). As part of installing this driver (version: 352.39), the existing driver will be uninstalled.
Are you sure you want to continue? (Answer: Continue installation)
-> Running distribution scripts
executing: '/usr/lib/nvidia/pre-install'...
-> done.
-> The distribution-provided pre-install script failed! Are you sure you want to continue? (Answer: Continue installation)
WARNING: One or more modprobe configuration files to disable Nouveau are already present at: /etc/modprobe.d/nvidia-installer-disable-nouveau.conf. Please be sure you have reboo
ted your system since these files were written. If you have rebooted, then Nouveau may be enabled for other reasons, such as being included in the system initial ramdisk or in y
our X configuration file. Please consult the NVIDIA driver README and your Linux distribution's documentation for details on how to correctly disable the Nouveau kernel driver.
-> For some distributions, Nouveau can be disabled by adding a file in the modprobe configuration directory. Would you like nvidia-installer to attempt to create this modprobe f
ile for you? (Answer: Yes)
-> One or more modprobe configuration files to disable Nouveau have been written. For some distributions, this may be sufficient to disable Nouveau; other distributions may requ
ire modification of the initial ramdisk. Please reboot your system and attempt NVIDIA driver installation again. Note if you later wish to reenable Nouveau, you will need to de
lete these files: /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
-> Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. (Answer: Yes
)
-> Installing both new and classic TLS OpenGL libraries.
-> Installing both new and classic TLS 32bit OpenGL libraries.
-> Install NVIDIA's 32-bit compatibility libraries? (Answer: Yes)
-> Uninstalling the previous installation with /usr/bin/nvidia-uninstall.
-> nvidia-installer will install the libvdpau and libvdpau_trace libraries that were included with this installer package. These libraries are available separately through the li
bvdpau project and will be removed from the NVIDIA Linux driver installer package in the future, so it is recommended that VDPAU users install libvdpau separately, e.g. by using
packages available from their distributions, or by building from the sources available at:
http://people.freedesktop.org/~aplattner/vdpau
-> Searching for conflicting files:
-> done.
-> Installing 'NVIDIA Accelerated Graphics Driver for Linux-x86_64' (352.39):
executing: '/sbin/ldconfig'...
-> done.
-> Driver file installation is complete.
-> Installing DKMS kernel module:
ERROR: Failed to run `/usr/sbin/dkms build -m nvidia -v 352.39 -k 3.13.0-55-generic`:
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=3.13.0-55-generic module KERNEL_UNAME=3.13.0-55-generic; make -C uvm module KERNEL_UNAME=3.13.0-55-generic KBUILD_EXTMOD=/var/lib/dkms/nvidia/352.39/build/uvm.
...(bad exit status: 2)
ERROR (dkms apport): binary package for nvidia: 352.39 not found
Error! Bad return status for module build on kernel: 3.13.0-55-generic (x86_64)
Consult /var/lib/dkms/nvidia/352.39/build/make.log for more information.
-> error.
ERROR: Failed to install the kernel module through DKMS. No kernel module was installed; please try installing again without DKMS, or check the DKMS logs for more information.
ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log' for details. You may find suggestions on fixing installation problems in the README availabl
e on the Linux driver download page at www.nvidia.com.
我不知道为什么我会收到此错误,也不知道如何修复它。
我已将所有内容打包在Maven项目中。布局就是这样:
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.068 sec <<< FAILURE! - in soy.wimmer.CucumberIT
Feature: Cucumber with Java8 Time elapsed: 0.051 sec <<< ERROR!
cucumber.runtime.CucumberException: Failed to instantiate class soy.wimmer.CucumberStepdefs
[…]
Caused by: java.lang.reflect.InvocationTargetException: null
[…]
Caused by: cucumber.runtime.CucumberException: java.lang.IllegalArgumentException: Wrong type at constant pool index
[…]
Caused by: java.lang.IllegalArgumentException: Wrong type at constant pool index
at sun.reflect.ConstantPool.getMemberRefInfoAt0(Native Method)
at sun.reflect.ConstantPool.getMemberRefInfoAt(ConstantPool.java:47)
at cucumber.runtime.java8.ConstantPoolTypeIntrospector.getTypeString(ConstantPoolTypeIntrospector.java:37)
at cucumber.runtime.java8.ConstantPoolTypeIntrospector.getGenericTypes(ConstantPoolTypeIntrospector.java:27)
at cucumber.runtime.java.Java8StepDefinition.<init>(Java8StepDefinition.java:45)
at cucumber.runtime.java.JavaBackend.addStepDefinition(JavaBackend.java:162)
at cucumber.api.java8.En.Given(En.java:190)
at soy.wimmer.CucumberStepdefs.<init>(CucumberStepdefs.java:8)
[…]
Results :
Tests in error:
Failed to instantiate class soy.wimmer.CucumberStepdefs
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
我在pom.xml中包含的依赖项是:
./src/test/java/soy/wimmer/CucumberIT.java
./src/test/java/soy/wimmer/CucumberStepdefs.java
./src/test/resources/cucumber/cucumber-java8.feature
./pom.xml
此外,pom.xml仅加载编译器和故障安全插件。
我对CucumberIT.java的定义:
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
我的功能定义:
package soy.wimmer;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:cucumber")
public class CucumberIT {
}
这是我的步骤定义:
Feature: Cucumber with Java8
As a developer
I want to use Cucumber-java8
So that I have nicer step definitions
Scenario: Let's try it
Given I have some dummy code
When I try to test it
Then it should work with cucumber-java8
知道我在这里做错了吗?
答案 0 :(得分:10)
问题的产生是因为Cucumber的Java8方言使用了Oracle JDK8的实现细节。
我正在使用Debian打包的OpenJDK8,这会导致常量池的组织不同。当我尝试使用Oracle的JDK8时,一切都按预期工作。
如果您想亲自尝试,我在github上发布了完整的示例项目:https://github.com/mawis/cucumber-java8-test
我还在这里报告了yellow-jvm问题跟踪器中的一个错误:https://github.com/cucumber/cucumber-jvm/issues/912
您可以查看问题跟踪器,看看问题是否会在将来修复。
现在如果你想使用cucumber-java8,你似乎必须使用Oracle的JDK实现。
(解决这个问题的名声属于Holger以及他对这个问题的评论。我只是想把这个答案写成摘要。)
答案 1 :(得分:7)
只需使用最近发布的1.2.5
版本。它解决了接受的答案引用的错误。