Error: Cannot invoke "org.springframework.graphql.test.tester.GraphQlTester.document(String)" because "this.graphQlTester" is null
Getting the above error. Have checked the jar files and they exist. But still can not find the autowiring being done in logs (with debug level in root).
package com.reports.controller;
import com.reports.entity.ReportDetails;
import com.reports.service.ReportDetailsService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest;
import org.springframework.context.annotation.Import;
import org.springframework.graphql.test.tester.GraphQlTester;
@Import(ReportDetailsService.class)
@GraphQlTest(ReportsController.class)
public class ReportsControllerIntTest {
@Autowired
GraphQlTester graphQlTester;
@Test
public void testReadAllReportsShouldReturnAllReports() throws Exception {
String query = """
query {
readAll {
id
reportName
columns
}
}
""";
graphQlTester.document(query)
.execute()
.path("readAll")
.entityList(ReportDetails.class)
.hasSizeGreaterThan(1);
}
}