background preloader

TEST

Facebook Twitter

JMeter - Apache JMeter™ Gatling Project - Stress Tool. Test Driven - Code Like This. Test-Driven by Alex Chaffee alex @ stinky.com Intended Audience Developers or QA EngineersFamiliar with Unit Testing (optional)Want more detail on Automated Testing in generalWant to know the case for Test-Driven DevelopmentWant to know style tips and gotchas for Testing and TDD Red, Green, Refactor First, write a test and watch it fail Make sure it's failing for the right reason!

Test Driven - Code Like This

Make it green, then make it clean Addicted to green You get a little rush every time a new test passesSteady, incremental feeling of progressDon't write code all day without knowing if it works Three As Arrange (set up preconditions)Act (call production code)Assert (check the results) Assert The heart of a unit testAn assertion is a declaration of truthFailed assertion -> incorrect behavior"assert your postconditions"Example: Set set = new MySet(); set.add("ice cream"); assertTrue(set.contains("ice cream")); In RSpec, "assert" is called "should" One Step At A Time The Null Test Test List Fake it till you make it Simple Rule.

Fest - Fixtures for Easy Software Testing. FEST is a collection of libraries, released under the Apache 2.0 license, whose mission is to simplify software testing.

fest - Fixtures for Easy Software Testing

It is composed of various modules, which can be used with TestNG or JUnit. Our users include: Google, Square, Eclipse Foundation, Oracle, IBM, Guidewire, and many more! For more details, like user testimonials and news, please visit the project's home page. GUI Functional Swing Testing This module provides a simple and intuitive API for functional testing of Swing user interfaces, resulting in tests that are compact, easy to write, and read like a specification. FEST makes troubleshooting failures a lot easier.

The following example simulates a user logging-in into a Swing application. Dialog.comboBox("domain").select("Users");dialog.textBox("username").enterText("alex.ruiz");dialog.button("ok").click();dialog.optionPane().requireErrorMessage() .requireMessage("Please enter your . *"); // regular expression matching Fluent Assertions. Mockito. 06-10-2012: Mockito 1.9.5 released!

Mockito

See the release notes. Should appear in maven central shortly. CDI et l’injection de mock pour les tests unitaires. Schuchert - Mockito.LoginServiceExample. Package com.om.example.loginservice; import org.junit.Test;import static org.mockito.Mockito.*; public class LoginServiceTest { @Test public void itShouldSetAccountToLoggedInWhenPasswordMatches() { IAccount account = mock(IAccount.class); when(account.passwordMatches(anyString())).thenReturn(true); IAccountRepository accountRepository = mock(IAccountRepository.class); when(accountRepository.find(anyString())).thenReturn(account); LoginService service = new LoginService(accountRepository); service.login("brett", "password"); verify(account, times(1)).setLoggedIn(true); }} Test Description Things Created for Compilation.

schuchert - Mockito.LoginServiceExample

Mockito in six easy examples. Mockito is a fantastic mock library for Java.

Mockito in six easy examples

I’m fascinated by how easy it is to use, compared to other things out there both in the Java and .NET world. Here is everything you need to know to get started in six really easy examples. First of all, get mockito from Almost everything really interesting can be imported with the org.mockito.Mockito class (or a static import of its methods, which I’ll use in this post). So let’s get right into it. To create a stub (or a mock), use mock(class). Import static org.mockito.Mockito.*; import static org.junit.Assert.*; import java.util.Iterator; import org.junit.Test; .... This example creates a mock iterator and makes it return “Hello” the first time method next() is called.

Stubs can also return different values depending on arguments passed into the method. @Test public void with_arguments(){ Comparable c=mock(Comparable.class); when(c.compareTo("Test")).thenReturn(1); assertEquals(1,c.compareTo("Test")); } Selenium - Web Browser Automation.