background preloader

Gatling Project - Stress Tool

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! 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

guava-libraries - Guava: Google Core Libraries for Java 1.5+ Riemann - A network monitoring system 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. 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 Here are some examples: Fluent Reflection

Git: Your New Best Friend [Server Side Essentials] Introduction This article introduces version control and Git without assuming you have any prior knowledge or programming experience. Because of its introductory nature, certain details are simplified or omitted and the use of the Git Graphical User Interface (Git GUI) is emphasized. Version control is the process of recording the history of changes to files as they are modified. protect against changes – accidental or otherwise – and be able to access a known good version of a filetrack down problems and make fixes to previous versions of filesallow more than one person to modify project files simultaneously (programmers refer to this as parallel development)retrieve an older set of files (if requested by a customer or manager, for example) The first version control (VC) tool, SCCS, was written in 1972 and since that time there have been major advances in the way VC tools are used. Git runs on Windows, Mac OS X, Linux and UNIX. Concepts Installing Git Starting to Use Git $ git init <! ...

Sonar CDI et l’injection de mock pour les tests unitaires L’injection de dépendances avec CDI me semble vraiment très intéressante en terme d’usabilité et de lisibilité du code. La seule chose qui me dérange un peu est le manque de facilité à tester un objet utilisant l’injection de dépendances. Ou, plutôt, comment utiliser un framework de mock et injecter un mock sur lequel j’ai la main en test. Je préviens d’avance. Voyons voir sur un exemple simple comment procéder pour arriver à utiliser un framework tel que Mockito. Tout d’abord, voilà mes classes et l’interface côté implémentation. L’interface représentant le service que je vais vouloir mocker par la suite. public interface MyService { String foo(); Son implémentation par défaut : public class DefaultMyService implements MyService { public String foo() { return "DefaultMyService.foo()" ; La classe dans laquelle le service est injecté par constructeur : public class MyApplication { private MyService myService; @Inject public MyApplication(MyService myService) { this .myService = myService; app.run();

Why programmers work at night [This essay has been expanded into a book, you should read it, here] Image via Wikipedia A popular saying goes that Programmers are machines that turn caffeine into code. And sure enough, ask a random programmer when they do their best work and there’s a high chance they will admit to a lot of late nights. At the gist of all this is avoiding distractions. I think it boils down to three things: the maker’s schedule, the sleepy brain and bright computer screens. The maker’s schedule Paul Graham wrote about the maker’s schedule in 2009 – basically that there are two types of schedules in this world (primarily?). On the other hand you have something PG calls the maker’s schedule – a schedule for those of us who produce stuff. This is why programmers are so annoyed when you distract them. Because of this huge mental investment, we simply can’t start working until we can expect a couple of hours without being distracted. The sleepy brain But even programmers should be sleeping at night. Fin Fin

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 package com.om.example.loginservice; public interface IAccount { void setLoggedIn(boolean value); boolean passwordMatches(String candidate);}

Chapter 4. Resources Java's standard java.net.URL class and standard handlers for various URL prefixes unfortunately are not quite adequate enough for all access to low-level resources. For example, there is no standardized URL implementation that may be used to access a resource that needs to be obtained from the classpath, or relative to a ServletContext. While it is possible to register new handlers for specialized URL prefixes (similar to existing handlers for prefixes such as http:), this is generally quite complicated, and the URL interface still lacks some desirable functionality, such as a method to check for the existence of the resource being pointed to. 4.2. The Resource interface Spring's Resource interface is meant to be a more capable interface for abstracting access to low-level resources. public interface InputStreamSource { InputStream getInputStream() throws IOException; } Some of the most important methods from the Resource interface are: 4.3. 4.3.3. 4.3.4. 4.3.5. Table 4.1. 4.5. 4.6. 4.7.

Mockito in six easy examples Mockito is a fantastic mock library for Java. 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). 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")); }

Mockito 06-10-2012: Mockito 1.9.5 released! See the release notes. Should appear in maven central shortly. Mockito is a mocking framework that tastes really good. "We decided during the main conference that we should use JUnit 4 and Mockito because we think they are the future of TDD and mocking in Java" - Dan North, the originator of BDD More quotes Over 15000 downloads of 1.9.0 version ('12), excluding maven/Gradle users. More about the user base Download mockito-all-x.x.x.jar and put it on the classpath. Then you can verify interactions: Or stub method calls Click here for more documentation and examples. If you have any suggestions, find documentation unclear or you found a bug, write to our mailing list. Mockito is served to you by Szczepan Faber and friends. Firstly, hats down before EasyMock folks for their ideas on beautiful and refactorable mocking syntax. Special thanks to Steve Christou for setting up the continuous builds at his Hudson server. Thanks to YourKit for the profiler!

Related: