All about...hybris Testing

von

Michael Albrecht - Java CAT
team neusta GmbH

Naming Conventions

  • allg. Testmethoden und Klassen
  • u.a. @UnitTest bzw. @IntegrationTest Annotations

Toolset

  • Junit 4
  • Hamcrest
  • Mockito
  • ...

My first UnitTest

package de.neusta.hybris.wishlist;

...
@UnitTest
public class WishlistModelTest
{

    @Test
    public void testCreatingNewWishlistForCustomerWithProduct()
    {
        final CustomerModel customer = new CustomerModel();
        customer.setUid("hans@dampf.de");
        final ProductModel product = new ProductModel();
        product.setCode("1234");

        final WishlistModel newWishlist = new WishlistModel();
        newWishlist.setCustomer(customer);

        final WishlistEntryModel newEntry = new WishlistEntryModel();
        newEntry.setProduct(product);

        newWishlist.setEntries(Arrays.asList(newEntry));

        assertThat(newWishlist.getEntries().iterator().next().getProduct().getCode(), is("1234"));
        assertThat(newWishlist.getCustomer().getUid(), is("hans@dampf.de"));
    }
}

My First Integrationtest

Code

Erklärtext