在我的java春天mvc中,我试图用黄瓜和硒进行测试。 我有以下类,它负责调用驱动程序。硒:依赖注射不起作用
@Service
public class BaseUtil {
public void caller(){
System.out.println("Caller Firefox driver here!!!!!!!");
}
}
,然后在步骤定义类我要去,使依赖注入步骤:
@Component
public class StepDefenitions{
@Autowired
BaseUtil base;
@Given("^I want to register into the main forum$")
public void i_want_to_register_into_the_main_forum() throws Throwable {
base.caller();
}}
但它与
java.lang.NullPointerException
at com.exercise.StepDefenitions.i_want_to_register_into_the_main_forum(StepDefenitions.java:26)
那么,为什么@Autowierd
不抱怨在这里工作?
“StepDefenitions”是一个弹簧管理bean吗? – Jens
延斯是对的。您是否在StepDefinitions类中拥有@Component或@ Service类 – pvpkiran
否它包含黄瓜功能文件的步骤。但是,我不知道如果我回答你的问题@Jens – Salman