ads1

четверг, 10 декабря 2015 г.

12 tools for the integration and unit-tests in Java

pic0

I believe that the development of software - something more than a job. I see myself as a craftsman, which is every day trying to get better. The most "simple" way to do this - to find a few good tools and answer the following questions:
  • When should I use the instrument X?
  • How should I use the instrument X?
Automated testing - a very important part of software development, but developers blog posts about a little-used tools. This article also allow you to look into my "toolbox". I'll talk about 12 libraries and frameworks that I use for writing unit- and integration test, and provides links to pages that help you understand how to use them.

Look into my toolbox

Before you can use the tools described below, you need to set up an assembly that automatically starts the integration and unit-tests. I have 2 notes on this subject:
Now you are ready to look at my instruments more closely. I divided them into categories to make it easier to navigate.
So, here are 12 tools that I use in the integration and unit-testing.

Starting the test

JUnit - a framework that I use for unit-, and for integration tests. I like it very much, because he is the most popular, so has many extensions. Also, if you have a problem - a solution will be easy.
NestedRunner - extension for JUnit, which allows you to run the test methods of nested classes. Like NestedRunner for several reasons:
  • You can replace the long method names in the class hierarchy in the style of BDD;
  • You can get rid of duplicate code by moving it to the installation methods in the relevant sub-classes;
  • You can declare constants in nested classes and associate them with the test that these constants are needed.
davaprovider-junit - extension for JUnit, which allows to write tests using parameterized TestNG as the dataprovider. This is a big improvement over the usual way of writing parameterizedtests, which, frankly, not very much.

Additionally:

Layouts plugs substitution

Mockito - the most popular framework with support for prototyping unit-tests. I like it because of the simple API, many useful features and excellentdocumentation.
Greenmail - e-mail server that supports SMTP, POP3 and IMAP-enabled SSL-connection. I like it because of the ease of use. When I was looking for a debug server e-mail, reviewing several alternatives, focused on Greenmail, because it worked exactly as I wanted.
MockFtpServer - a library that provides two different implementations of FTP-server ("cap" and "snag"), which can be used to test variousscenarios. If you need to test code that interacts with the FTP-server, our choice - MockFtpServer.

Additionally:

Assertions

Hamcrest provides tools for writing assertions (assertions) for unit- and integratsionnayh tests.I use it with Spring MVC TestFramework.
AssertJ provides a flexible API for writing statements with useful error messages improves the readability of the test code, allows you to turn the tests into executable specifications that adhere to the desired object-oriented language.

Additionally:

Test data access code

H2 - fast database is useful to write integration tests that run on the local development machine.
DbUnit - extension for JUnit, which can be used to initialize a database to a known state before each test integration and filling the database that contains the data. In DbUnit it has its flaws, but it is a very useful tool that allows you to share test data and test code.

Additionally:

Spring Testing Applications

Test Spring - Swiss army knife for writing automated tests. It provides first-class support for writing unit- and integration tests for applications using Spring.
Test DbUnit Spring - integrate DbUnit who want to get into String Test. If you need to write tests for data access application using Spring, and a relational database, the Spring Test DbUnit to help you.

Additionally:

Комментариев нет:

Отправить комментарий