Ausgabe
Ich begegne den folgenden Fehler beim Ausführen meines Projekts als Konfiguration der Unit -Test in Intellij:Code: Select all
/Users/francislainycampos/IdeaProjects/so-be-automation/src/test/java/com/francislainy/sobeautomation/steps/MySteps.java:14:30
java: variable restClient not initialized in the default constructor
Code: Select all
@Slf4j
@Component
@AllArgsConstructor
public class RestClient {
public RequestSpecification getRequestSpecification() {
// Rest Assured config here
}
}
Code: Select all
@CucumberContextConfiguration
@SpringBootTest(classes = TestConfig.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CucumberSpringConfiguration {}
Code: Select all
@ComponentScan(basePackages = {"com.francislainy.sobeautomation"})
@EnableAutoConfiguration
public class TestConfig {}
Code: Select all
@RequiredArgsConstructor
public class MySteps {
private final RestClient restClient;
private Response response;
@Given("I send a GET request to the Bored API")
public void iSendAGETRequestToTheBoredAPI() {
response = restClient.getRequestSpecification().get("https://www.boredapi.com/api/activity");
}
}
Code: Select all
org.projectlombok
lombok
provided
io.cucumber
cucumber-spring
test
org.springframework.boot
spring-boot-starter-test
test
< /code>
[h4] Was ich ausprobiert habe < /h4>
[list]
[*] [b] Überprüfte Lombok Annotation Processing < /strong>: Annotationsverarbeitung ist < strong> aktiviert [/b] in Intellij (Settings > Build, Execution, Deployment > Compiler > Annotation Processors
[*] Manuell einen Konstruktor hinzugefügt : Wenn ich einen Konstruktor in mysteps.java explizit definiere, wird das Problem behoben: < /li>
änderte den Umfang der Lombok -Abhängigkeit , um zu kompilieren oder als nicht angegebener Standardbereich zu erlassen.
[*] ausprobiert verschiedene Versionen , sowohl mit Lombok 1.18.30 als auch mit den neuesten 1.18.36.
[/list]
jedoch die einzige
https://github.com/francisny/so-be-automation
Danke.