[JAVA]null value in unit test case code
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Empieza ejecutando el comando documentado de swagger-codegen e inspeccionando la PetApiTest.java generada, especialmente addPetTest. Sigue la plantilla de generación de tests de Java y determina cómo podrían derivarse los objetos de solicitud y las aserciones a partir de la entrada de OpenAPI. La tarea estaría terminada cuando los tests generados inicialicen datos de solicitud utilizables, realicen aserciones significativas y este TODO deje de estar sin resolver.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
issue in English
Summary
I try to generate code by following command,
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i https://petstore.swagger.io/v2/swagger.json \
-l java \
-o samples/client/petstore/java
When it done, I open PetApiTest.java, then I saw a piece of test case code,
@Test
public void addPetTest() throws Exception {
Pet body = null;
api.addPet(body);
// TODO: test validations
}
Now, my issue is that I hope the body value shouldn't be null, and I hope the TODO should be completed.
Swagger-codegen version
2.4.43
Suggest a fix/enhancement
It is expected that the unit test code is complete, that is, it can create and initialize different objects, and make assertions.
Additional information: I'm working in a test technology team that provide technology for test engineer. Due to the rise of AI technology, especially the LLM like ChatGPT, my manager wants to introduce the technology to resolve some problems. Now he wants to input a JSON file written in OpenAPI Specification like swagger.json to a tool, then hope that the tool can produce some request data which can be used for calling RESTful API.
Okay. That's all, thank you.
issue in Chinese
Because I'm Chinese, I remain my Chinese issue.
问题概述
我尝试按以下命令生成代码,
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i https://petstore.swagger.io/v2/swagger.json \
-l java \
-o samples/client/petstore/java
生成后,我打开PetApiTest.java,看到其中一个测试用例:
@Test
public void addPetTest() throws Exception {
Pet body = null;
api.addPet(body);
// TODO: test validations
}
现在问题是,我希望body值不是null,并且希望TODO代码已经自动写好了。
Swagger-codegen version
2.4.43
Suggest a fix/enhancement
希望单元测试代码是完全的,也就是能够创建和初始化不同的对象,并且做出断言。
- Lenguaje dominante
- Mustache
- Estrellas
- 17.8k
- Forks
- 6k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de swagger-api/swagger-codegen
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
swagger-api/swagger-codegen#12755 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
swagger-api/swagger-codegen#12445 ·
-
security vulnerability
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
swagger-api/swagger-codegen#11942 ·
-
[JAVA] Non compilable enums generated with property errorOnUnknownEnum=truePosiblemente ocupada @HiagoW la tomó hace 1460 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
swagger-api/swagger-codegen#11812 · 1 reacción ·
-
security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
swagger-api/swagger-codegen#11594 ·
Todos los issues de swagger-api/swagger-codegen
Issues similares
-
[Test] flaky: autopay refundAllocation 2000-sequence property test times out at 5 s under CI loadAbiertotech-debt
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
LanternOps/breeze#8940 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
shackett/shackett-utils#19 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
components-web-app/docs#245 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
FujiNetWIFI/fujinet-lib#186 ·
Los mantenedores suelen responder en 1 día
-
`test_logging_tool` response omits resultType on the 2026-07-28 wirePosiblemente ocupada @lnuxe la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
modelcontextprotocol/conformance#562 ·
Los mantenedores suelen responder en 7 días