background preloader

Code testing

Facebook Twitter

Load Testing by Example - Best Practices - Web Performance. Overview The purpose of this tutorial is to present some of the best practices we have developed at Web Performance. Through our Load Tester product development and load testing service experiences, we have found some easy tips and general strategies that can help make load testing efforts more successful. They are presented here in hopes of making all load testing efforts more successful. General Strategies As a tester, our job is to provide the best possible feedback on the readiness of an application as early as possible in the development cycle. Of course in the real world, deadlines are always tight and testing begins later than it should. We've found a few simple rules that have helped make our load testing projects more effective. 1. Testing Steps Scenario Selection When selecting scenarios to test from the group of all possible scenarios, we rate each scenario by two aspects: Difficulty of Simulation and Importance.

Configuration Management Some pointers: Testcase Construction Metadata. Testing. Automating JMeter tests with Maven and Jenkins. In this post, I will show how to integrate the popular load testing tool JMeter in a Maven build. The goal is to allow every developer to easily develop and execute JMeter tests on his local machine.

There will be no need to learn a new commandline utility or to install separate tools. Everything will be possible via some simple maven goals. With this setup, it is also easy to create a Jenkins job, that allows execution of JMeter tests against a testing environment with a single click. Integrating JMeter with Maven There are two plugins, that allow integration of JMeter tests in a Maven build: jmeter-maven-plugin and chronos-maven-plugin. Points 1) to 3) are satisfied by both plugins. The following code- and configuration-snippets are taken from the example project jmeter-maven-example, which is available on GitHub.

The tests must be placed in the folder /src/test/jmeter. The tests are most likely executed in various envorinments. Executung JMeter tests with Jenkins-CI Reporting Result. TestCafé: Web Testing Framework | DevExpress.

Software metrics

Testing Web Applications with Spring Framework 3.2. Sam Brannen Swiftmind Rossen Stoyanchev VMware @sam_brannen Spring and Java Consultant @ SwiftmindDeveloping Java for over 14 yearsSpring Framework Core CommitterSpring TrainerLead author of Spring in a NutshellPresenter on Spring, Java, and testing @rstoya05 Staff Engineer, VMwareSpring Framework CommiterFocus on Web developmentSpring MVC, Spring Web FlowTeaching and consulting New testing features in the Spring FrameworkSpring MVC Test (spring-test-mvc) Spring TestContext FrameworkWeb Application ContextsContext InitializersContext HierarchiesSpring MVC Test FrameworkServer-side Spring MVC TestsClient-side RestTemplate TestsQ&A JUnit / TestNGSpring 2.5 / 3.0 / 3.1 / 3.2Integration testing with SpringSpring TestContext FrameworkSpring MVC / Test Revised in Spring 3.2 ...

Unit and integration testing Convention over Configuration public class OrderServiceTests { @Test public void testOrderService() { … }} Tracks context for current testDelegates to a ContextLoaderCaches the ApplicationContext. Introducing Spring MVC test framework. Spring MVC comes with a very useful test framework, which allows doing in-depth testing without even starting a web container. If you struggle maintaining any application based on Spring MVC, this post will show you the basics of the Spring MVC test framework. What am I testing? We can distinguish 3 levels of testing for Spring MVC controllers: unit tests: we test only the logic of the controller. Dependencies are mocked/stubbed, there's no Spring, nor web container. This post focuses on the second level of testing, by using the Spring MVC test framework, available as of Spring 3.2.

Testing inbound/outbound serialization (e.g. The Spring MVC test framework makes all of this a breeze, let's see how to use it to test a simple web controller. The controller to test The controller we're about to test is the usual "Hello World" example for Spring MVC: @Controller public class SimpleController { @RequestMapping("/hello") @ResponseBody public String helloWorld() { return "Hello World! " Conclusion. The Future of Web MVC Testing. Ok, ok, I'm excited. Right now I just was able to hack my way through a test with Spring 3.2 and the web context. The method I ended up writing looked like this: @Test public void tryStartQuiz() throws Exception { this.mvc.perform(get("/engine/start/james")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.quiz_id").exists()); } How did I get here?

Here is the top of my test class: The MockMvc object is created after injecting a test WebApplicationContext object, which is driven via the @WebAppConfiguration above. There are several static imports that make life easier, as outlined in this great slide show from the MVC team (Rossen and friends): import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.setup.MockMvcBuilders. Does Spring MVC Spring 3.2 test the web.xml configuration. » Maven + JUnit + ClassFormatError: Absent Code attribute in method that is not native or abstract in class file dominikdorn.com. 11May 2010 Once in a while one stumbles upon an error message like this java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/Session This happens if your code compiles against incomplete classes, like the JavaEE6 Api and your Unit tests try to access code thats not there.

JUnit will simply fail and mark the test as error, printing something like this Tests in error: initializationError(com.dominikdorn.dc.passwordReset.SimplePasswordResetServiceTest) and the corresponding surefire text file starts like this: ------------------------------------------------------------------------------- Test set: com.dominikdorn.dc.passwordReset.SimplePasswordResetServiceTest ------------------------------------------------------------------------------- Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.022 sec <<< FAILURE! The Solution You have to compile against real-implementations of the classes. JavaMail: javax/mail/Session. Spring Framework 3.2 RC1: New Testing Features.

As Juergen Hoeller mentioned in his post announcing the release of Spring Framework 3.2 RC1, the Spring Team has introduced some exciting new features in terms of testing support. Most importantly, we've added first-class support for testing web applications. [1] Please note: this is a cross post from my Swiftmind company blog. In this post we'll first take a look at some of the general new testing features in the Spring Framework, and then we'll go into detail regarding support for testing with a WebApplicationContext as well as request and session scoped beans. We'll close with a look at support for ApplicationContextInitializers and a brief discussion of the road map for testing with application context hierarchies. Rossen Stoyanchev will later follow up with a detailed post on the new Spring MVC Test framework that provides first-class support for testing Spring MVC applications. Build and Dependencies Generic Factory Methods Mock Objects JDBC Testing Support Conventions Injecting Mocks.

Spring Framework 3.2 RC1: Spring MVC Test Framework. Last week Juergen Hoeller announced the release of Spring Framework 3.2 RC1 and Sam Brannen discussed exciting additions in its spring-test module such as support for WebApplicationContext's and upcoming plans for loading a hierarchy of contexts. Today I will continue this subject and describe another exciting spring-test addition. In 3.2 RC1 we've added first class support for testing Spring MVC applications both client-side and server-side.

Background The Spring MVC Test framework discussed here originates from a standalone project on Github, where features evolved for over a year with continuous feedback from many users. As of Spring 3.2 RC1, the code from the standalone project has been added to the Spring Framework and is available in the spring-test module, under slightly modified package names, and with support for 3.2 specific features such as async requests and others. With that out of the day, let's have a closer, more detailed look. Server-Side Support Static Imports Next Steps. Java: Is assertEquals(String, String) reliable. Java - AssertContains on strings in jUnit.

Using HSQLDB to unit test database access code | Shopzilla Tech Blog. Writing unit tests for code that accesses the database is a recurring challenge for Java developers. This post will describe a technique we’ve used successfully on a number of database-intensive projects: using HSQLDB as an in-memory database so that the database access code can be thoroughly tested without dependencies on external resources.

First a description of our environment: our production databases are Oracle. Our code is primarily used in web services running in Tomcat 6, but occasionally used in command-line applications as well. This technique was developed for code that uses the JPA annotations and API, with Hibernate 3 as the JPA implementation. We also use Spring, for both dependency injection and transaction handling. (Naturally this approach won’t work if your SQL uses database-specific features that HSQLDB doesn’t support. These are unit tests, not integration tests.

Using this technique requires completing four steps: 1. 1. 2. 3. 4. Whew! Performance vs. load vs. stress testing. Here's a good interview question for a tester: how do you define performance/load/stress testing? Many times people use these terms interchangeably, but they have in fact quite different meanings. This post is a quick review of these concepts, based on my own experience, but also using definitions from testing literature -- in particular: "Testing computer software" by Kaner et al, "Software testing techniques" by Loveland et al, and "Testing applications on the Web" by Nguyen et al. Update July 7th, 2005 From the referrer logs I see that this post comes up fairly often in Google searches. I'm updating it with a link to a later post I wrote called 'More on performance vs. load testing'. Performance testing The goal of performance testing is not to find bugs, but to eliminate bottlenecks and establish a baseline for future regression testing.

A clearly defined set of expectations is essential for meaningful performance testing. Load testing Examples of volume testing: Stress testing Conclusion. Integration testing. Purpose[edit] The purpose of integration testing is to verify functional, performance, and reliability requirements placed on major design items. These "design items", i.e. assemblages (or groups of units), are exercised through their interfaces using black box testing, success and error cases being simulated via appropriate parameter and data inputs.

Simulated usage of shared data areas and inter-process communication is tested and individual subsystems are exercised through their input interface. Test cases are constructed to test whether all the components within assemblages interact correctly, for example across procedure calls or process activations, and this is done after testing individual modules, i.e. unit testing. The overall idea is a "building block" approach, in which verified assemblages are added to a verified base which is then used to support the integration testing of further assemblages. Big Bang[edit] Top-down and Bottom-up[edit] Limitations[edit] References[edit] Selenium Test Automation with Maven. Today i want to help you manage your Automated GUI Tests (Selenium) better. In the past i have seen many different ways people handle this.

Some people just write those plain HTML TestCases with Selenium-IDE, store it somewhere on the HDD and run manually when needed. Others dont even use Selenium-IDE. They write pure Java for Example, and automate their execution with JUnit. Precondition I want plain HTML TestCases, created with Selenium-IDE. Solution First of all i create a Folder in my Project for the Selenium-Tests.

Folder Structure Example TestSuite Example Test Setup WebServer So i have my TestSuite in Place. If you are running multiple Projects on a CI-Server you might consider using a different Port-Number for each Project. Finally: Run the Tests Last but not least we need to run the tests. Now, whenever we execute mvn clean verify or even mvn clean install in console, the Tests are run and reports are stored within the target directory.

Conclusion We do have a complete and clean Setup. Seleniumworks. ChromeDriver - selenium. Download chromedriver Developed in collaboration with the Chromium team, the ChromeDriver is a standalone server which implements WebDriver's wire protocol. The ChromeDriver consists of three separate pieces. There is the browser itself ("chrome"), the language bindings provided by the Selenium project ("the driver") and an executable downloaded from the Chromium project which acts as a bridge between "chrome" and the "driver". This executable is called "chromedriver", but we'll try and refer to it as the "server" in this page to reduce confusion.

Requirements The server expects you to have Chrome installed in the default location for each system: 1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. Getting Started Read ChromeDriver user documentation Running ChromeDriver as a standalone process Since the ChromeDriver implements the wire protocol, it is fully compatible with any RemoteWebDriver client. Troubleshooting. Selenium Maven Plugin - Introduction. Automated Web Testing with Selenium IDE. Automated Web Testing with Selenium IDE by Eli Weinstock-Herman (tarwn) on October 26, 2011 in category UI Development. Article views: 17,882 Instapaper How long does it take to browse through a website after each build and make sure none of the pages have mysteriously blown up? 5 Minutes?

20? No time at all? Enter browser automation tools, such as Selenium. Note: This post is a walk-through for creating some automated browser test cases. The Smoke Test There are levels to automated testing, starting with “none” and ending with some fairly complex industry packages and/or in-house frameworks. Selenium IDE is a browser plugin that can record and playback actions we make in the browser. Pros: Free, Low up front time cost Cons: Tests are fragile*, Potential for lots of duplication*, tests run on local browser Neutral: There’s a learning curve but good documentation and quick feedback* * I’ll come back to these three points Getting Started Selenium IDE in the Firefox Menu Selenium IDE Test Suite . Effective out-of-container Integration Testing - 4Developers. Integration testing your Spring 3 & JPA 2.0 application. In my previous posts, I explained the following: Now, one thing that is missing in this picture is...

Testing DAO classes There is a presentation by Rod Johnson of Spring on testing with Spring that explains you what unit testing and what integration testing is, what mock objects are and some of the best practices. The presentation itself is from 2007 and while the general ideas haven't changed, the implementation techniques have. Therefore in this article I will show you how to integration test your DAO classes. I am going to use a JPA project for this, but the same test code will work for Hibernate as well. Integration Testing principles Integration testing is another level of tests; while unit tests test pieces of code in separation, integration tests test the bigger picture.

So, you should have a database set up, in a well known state. On this database you perform the tests. How does it, uhm, how does it work? You mess around with the database, add, update, remove. Alright! Dependencies. Integration testing with Spring and Jetty | coding and stuff. JBoss Java EE Spec Artifact. Unitils. UsesOfHamcrest - hamcrest - How people are using Hamcrest matchers - Hamcrest - library of matchers for building test expressions. Shazam/shazamcrest. On the subtle uses of Hamcrest tests. JUnit 4 Showcase – assertThat and Hamcrest Matchers | Software dev ramblings. jUnit ReleaseNotes4.4. Fest-assert-2.x Wiki. Tips and tricks · Fest-assert-2.x Wiki.

Unit testing. Writing Your First Unit Test. Writing good unit tests, Part 1: Follow your GUTs. Three rules for writing good unit tests. Unit Testing Best Practices. What your tests don't need to know will hurt you - The Code Whisperer. The Code Sheriff. You Shall Not Test Methods | Tomek's blog. Embrace Unit Testing.