Esta ocorrendo o seguinte erro ao executar ;
java.lang.NullPointerException: Cannot invoke "br.com.alura.leilao.model.Leilao.propoe(br.com.alura.leilao.model.Lance)" because "this.leilao" is null at br.com.alura.leilao.acceptance.steps.PropondoLanceSteps.quando_propoe_o_lance(PropondoLanceSteps.java:34) at ✽.Quando propoe o lance(classpath:features/propondo_lances.feature:6)
package br.com.alura.leilao.acceptance;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class) @CucumberOptions(features = "classpath:features")
public class LeilaoCucumberRunner {
}
package br.com.alura.leilao.acceptance.steps;
import java.math.BigDecimal; import java.util.List;
import org.junit.jupiter.api.Assertions;
import br.com.alura.leilao.model.Lance; import br.com.alura.leilao.model.Leilao; import br.com.alura.leilao.model.Usuario; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When;
public class PropondoLanceSteps {
private Leilao leilao;
private Lance lance;
@Given("Dado um lance valido")
public void dado_um_lance_valido() {
Usuario usuario = new Usuario("fulano");
new Lance(usuario, BigDecimal.TEN);
}
@When("Quando propoe o lance")
public void quando_propoe_o_lance() {
new Leilao("Tablet XPTO");
leilao.propoe(lance);
}
@Then("Entao o lance eh aceito")
public void entao_o_lance_eh_aceito() {
Assertions.assertEquals(1, leilao.getLances().size());
Assertions.assertEquals(BigDecimal.TEN, leilao.getLances().get(0).getValor());
}
}