Reference documentation shows the same MockMvcTester example twice in "Auto-configured Spring REST Docs Tests With Mock MVC"

Aperta Adatta ai principianti
#52,651 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, spring-boot
Ambito
documentation

Direzione di ricerca

Leggi la sezione Spring REST Docs e confronta i due file di esempio elencati nell’issue. Aggiorna l’esempio hamcrest e l’esempio che include in modo che usi MockMvc con perform, andExpect e andDo(document(...)), come descritto nell’issue. Verifica che gli esempi Hamcrest e AssertJ differiscano come promesso dal testo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status: waiting-for-triage

In the section Auto-configured Spring REST Docs Tests With Mock MVC (4.1.2), the text introduces a MockMvc example, then says "If you prefer to use the AssertJ integration, MockMvcTester is available as well, as shown in the following example" — but both code blocks are the same MockMvcTester example.

The two included sample files are identical except for their package (tag v4.1.2):

  • documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/hamcrest/MyUserDocumentationTests.java
  • documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/assertj/MyUserDocumentationTests.java

The hamcrest variant seems to have been overwritten with the AssertJ one when the two variants were introduced; the same duplication is present in v3.5.6 and v3.4.10. Before the split, the example used MockMvc (tag v3.3.5):

@Autowired
private MockMvc mvc;

@Test
void listUsers() throws Exception {
    this.mvc.perform(get("/users").accept(MediaType.TEXT_PLAIN))
        .andExpect(status().isOk())
        .andDo(document("list-users"));
}

Expected: the first example uses MockMvc with perform(...) / andExpect(...) / andDo(document(...)), so that the two examples actually differ as the text says.

Lingua principale
Java
Stelle
81.8k
Fork
43.5k
Merge medio
3g 13h
PR unite (30g)
90

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di spring-projects/spring-boot

Tutte le issue di spring-projects/spring-boot

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.