Gurke gibt mir einen Null auf @mock @mockbean oder @autowired [geschlossen]Java

Java-Forum
Anonymous
 Gurke gibt mir einen Null auf @mock @mockbean oder @autowired [geschlossen]

Post by Anonymous »

primero voy ein Exponer mi build.gradle ya que muchas veces me ha dado problema Solo por ESO: < /p>
Zunächst werde ich den Datei Build anweisen. Nach vielen Installationen habe ich gesehen, dass einige Male einige Abhängigkeiten zwischen ihnen inkompatibel sind. < /p>

Code: Select all

dependencies {
testImplementation platform('org.junit:junit-bom:5.12.1')
testImplementation platform('io.cucumber:cucumber-bom:7.21.1')
testImplementation platform('org.assertj:assertj-bom:3.27.3')

testImplementation 'io.cucumber:cucumber-java'
testImplementation 'io.cucumber:cucumber-junit-platform-engine'
testImplementation 'org.junit.platform:junit-platform-suite'
testImplementation 'org.assertj:assertj-core'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'jakarta.validation:jakarta.validation-api:3.1.1'
implementation 'io.cucumber:cucumber-core:7.21.1'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

< /code>
Tengo El Siguiente Runcucumbertest:
Abgesehen davon, Runcucumbertest, der die Klasse mit dem Läufer hat, hat viele Änderungen vorgenommen.
@Suite
@IncludeEngines("cucumber")
@SelectPackages("com.scotiabank")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.scotiabank")
@ActiveProfiles("test")
@ExtendWith(MockitoExtension.class)

public class RunCucumberTest{
@Mock
AlumnoDao alumnoDao; // -> here has mockValue
}

< /code>
y la siguiente Clase -Schritte:
und um die Schrittklasse zu beenden, die ich geändert habe und die nicht verdrahtet oder verdrahtet. < /p>

@ExtendWith({SpringExtension.class, MockitoExtension.class})  // Extiende con ambos
public class AlumnoServiceSteps {
@Autowired
private AlumnoDao alumnoDao; // -> here is null
private final StringNotSQLInjected stringNotSQLInjected= new StringNotSQLInjectedImpl();
private AlumnoService alumnoService= new AlumnoService(alumnoDao, stringNotSQLInjected);

//.... etc...

< /code>
Mi Problema es que alumnodao es null. />  Mein [url=viewtopic.php?t=18916]Problem[/url] ist, dass Alumnnodao auf dieser Seite des Codes null ist. Tags für Läufer und Schritte Klasse.
@Autowired
private AlumnoService alumnoService; // -> null

pl

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post