Intellij Unit -Testkonfiguration für Gurken fällt mit: "Variablen RESTClient nicht im Standardkonstruktor" -Fehler initiJava

Java-Forum
Anonymous
 Intellij Unit -Testkonfiguration für Gurken fällt mit: "Variablen RESTClient nicht im Standardkonstruktor" -Fehler initi

Post by Anonymous »

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
Die gleichen Tests funktionieren jedoch gut, wenn ich einen MVN -Test vom Terminal ausführe. />restclient.java

Code: Select all

@Slf4j
@Component
@AllArgsConstructor
public class RestClient {
public RequestSpecification getRequestSpecification() {
// Rest Assured config here
}
}
CumcumberspringConfiguration.java

Code: Select all

@CucumberContextConfiguration
@SpringBootTest(classes = TestConfig.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CucumberSpringConfiguration {}
TestConfig.java

Code: Select all

@ComponentScan(basePackages = {"com.francislainy.sobeautomation"})
@EnableAutoConfiguration
public class TestConfig {}
Mysteps.java

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");
}
}
pom.xml (relevante Abhängigkeiten)

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.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post