我遇到错误“找不到合适的构造函数。类必须具有用@Inject注释的一个(只有一个)构造函数或非私有的零参数构造函数。”而我正在使用Cucumber + Guice添加测试时。这是一个新的代码包。您对我缺少的东西有任何见识吗?
public class AWSServiceModule extends AbstractModule {
@Override
protected void configure() {
}
@Provides
@Singleton
public AWSBatch provideAwsBatchClient() {
return AWSBatchClientBuilder.standard()
.withCredentials(new DefaultAWSCredentialsProviderChain())
.build();
}
@Provides
@Singleton
public BatchJobClient provideTestBatchClient(final AWSBatch batchClient) {
return new BatchJobClient(batchClient, JOB_DEFINITION, JOB_QUEUE);
}
@Provides
@Singleton
public BatchJobIntegrationTest provideBatchJobIntegrationTest (
final BatchJobClient batchJobClient) {
return new BatchJobIntegrationTest(batchJobClient);
}
public class CucumberGuiceInjector implements InjectorSource {
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, CucumberModules.SCENARIO, new AWSServiceModule());
}
}
public class BatchJobSteps {
@Inject
private BatchJobIntegrationTest testJob;
@Given("^input file exists$")
public void input_file_exists() {
testJob.injectInputs();
}
@When("^application is run with the given scenario in FP mode$")
public void application_is_run_with_the_given_scenario_in_FP_mode() {
testJob.runBatchJob();
}
@Then("^the batch job generates options as expected and stores them in the designated bucket in S3")
public void the_batch_job_generates_options_as_expected_and_stores_them_in_the_designated_bucket_in_S3() {
testJob.assertTestResults();
}
}
public class BatchJobIntegrationTest extends BatchJobIntegrationTestBase {
public BatchJobIntegrationTest(final BatchJobClient batchJobClient) {
super(batchJobClient);
}
@Override
public void injectInputs() {
// TODO: get the S3 path parameter for input
Assert.assertTrue(true);
}
public void runBatchJob() {
// TODO: runBatchJob(BATCH_JOB_NAME);
Assert.assertTrue(true);
}
@Override
public void assertTestResults() {
// TODO: compare the batch output and expected output from S3
Assert.assertTrue(true);
}
@Override
protected ContainerOverrides getContainerOverrides() {
return null;
}
}