Problems with Junit

Asked

Viewed 106 times

0

I’m trying to run some tests on a small application for JAX-RS studies. The following error is shown when I try to run a test case to simulate a GET

org.junit.vintage.engine.support.UniqueIdReader 
lambda$apply$1
ADVERTÊNCIA: Could not read unique ID for Description; 
using display name instead: 
deveInserirUmAutor(br.com.sabium.test.AutorTest)
java.lang.NoSuchFieldException: fUniqueId

The funny thing is that my co-worker has the same project, with the same jars, is also presented the same errors, but Junit passes the tests and the data is persisted in the Database. Someone could help me?

Here is our Testing archive: `

package br.com.sabium.test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.junit.Before;
import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import br.com.sabium.projeto.model.Autor;

public class AutorTest {
    private Client client;
    WebTarget target;
@Before
public void before() {
    this.client = ClientBuilder.newClient();
    target = client.target("http://localhost:8080/AvaliacaoTest/api");
}

@Test
public void deveBuscarUmAutor() {
    Autor autor = target.path("/autor/1").request(MediaType.APPLICATION_JSON).get(Autor.class);
    assertEquals("Thiago", autor.getNome());
}

@Test
public void deveInserirUmAutor() {
    Autor autor = new Autor("Rodrigo", 20);
    Response output = target.path("/autor/").request(MediaType.APPLICATION_JSON)
            .post(Entity.entity(autor, MediaType.APPLICATION_JSON));
    System.out.println(output.getStatus());
    assertEquals(201, output.getStatus());
}

@Test
public void deveAtualizarUmAutor() {
    Autor autor = target.path("/autor/1").request(MediaType.APPLICATION_JSON).get(Autor.class);
    autor.setNome("Matheus da Silva");
    autor.setIdade(17);
    Response output = target.path("/autor/1/nome").request().put(Entity.entity(autor, MediaType.APPLICATION_JSON));

    System.out.println(output.getStatus());
    assertEquals(200, output.getStatus());
}

@Test
public void deveExcluirUmAutor() {
    Response output = target.path("/autor/10").request().delete();
    assertEquals(204, output.getStatus());
}
} 
  • Which version of Junit you are using?

  • Hello Bruno! I’m wearing Junit 5.4

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.