samedi 27 octobre 2018

Testing a group of parameters with JUnit in Netbeans

so I can't figured out how to use JUnit when I want to test this:

public int Agregar(int idcat, String nom, String desc)
    {
        int res = 0;
        Categoria nueva = new Categoria(idcat, nom, desc);

        DatosCategorias.add(nueva);
        res = 1;

        return res;
    }

This is what I do, clearly wrong, but I don't know the mistake, or how to formulate an appropiate solution to this.

   public void testAgregar_3args() {
        System.out.println("Agregar");
        int idcat = 1;
        String nom = "as";
        String desc = "asas";
        AuxCategorias instance = new AuxCategorias();
        int expResult = 1;
        int result = instance.Agregar(idcat, nom, desc);
        assertEquals(expResult, result);

I've been looking but there are really easy examples or really difficult. Pretty sure if I understand this, I can do the rest. Can anyone tell me how to do this? TIA

Aucun commentaire:

Enregistrer un commentaire