# Formulario

Vamos a implementrar un test y un formulario para el metodo save().

Crear el Mock e implementar el test

```java
            Color color = new Color();
            color.setActivo("si");
            color.setAutoincrementable(15);
            color.setIdcolor("rojo");
            List<UserInfo> list = new ArrayList<>();
            color.setUserInfo(list);
            Boolean expResult = true;
            Boolean save = unitTest.assertEquals(nameOfMethod(), true, colorRepository.save(color));
```

Si falla el Test dibujar la interfaz.

* Definimos un formulario form()
* Asignar el titulo&#x20;
* Crear un panel
* Agregar dos inputText con sus etiquetas
* Cerrar el panel
* Agregar un boton
* Cerrar el formulario
* Enviar un mensaje

```java
         if (!save) {
                /*
            Dibuja la interfaz
                 */
                unitTest.form();
             unitTest.formTitle("Registros de colores");
           unitTest.panel();

               unitTest.panelAddInputText(Arrays.asList(new InputText("idcolor", color.getIdcolor()),
                        new InputText("activo", color.getActivo())));

              unitTest.panelClose();
            unitTest.buttonGreen("Save");
               unitTest.formClose();

               unitTest.errorMessage("No se pudo guardar");

            }
```

Agregar el método save() en el init.

**Código**

## ColorTest.java

```java
```

## Ejecutar el Test.

Se generan los archivos

![](/files/-Lc1WvPxyjcRiIT5OhO6)

Abrimos unitreports.html

![](/files/-Lc1WvPzzoMeyf7UtZ5w)

## Ejecutar Nuevamente el Test

**Obsevamos que ColorTest no paso todos los test**

![](/files/-Lc1WvQ0vplk1ho-VsP6)

Fallo en el método save()

![](/files/-Lc1WvQ2UxU8DywnODpY)

## Abrir el archivo

![](/files/-Lc1WvQ4ndbI1l2GxiRW)

Se muestra el formulario con datos que no logro pasar el Test.

Mediante UnitView podemos tener una vista de los test que han fallado.

![](/files/-Lc1WvQ6SMHyn9jS45YC)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/jmoordbunit/testing-con-unitview/metodo-save.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
