Tag Archives: Integration Testing

Gulp, as a better Grunt? Automate your frontend development workflow fully!


Let’s quickly describe all the pros of having your development workflow automated and show the pros and cons of advanced grunt setup.

Then we’ll switch to Gulp – a new and pretty decent tool, with a very quick, easy and clean way to being configured. As a summary: I want to show all the things we can [and should have] configure as a current frontend developer. That is, f.e.: code linting, additional syntax compilation (coffee/jade/sass), files compression, adding comments, compiling fonts/vectors, unit/integration testing, CI, deployment, multiple environments configuration.

View abstraction for integration testing


View abstraction for integration testing

lib add Domino.find! method which waits for matching node 5 months ago
test add Domino.find! method which waits for matching node 5 months ago
.gitignore bundler-style gem publishing 2 years ago
.travis.yml travis: remove rubinius, add ruby 2.1.2 5 months ago
Gemfile bundler-style gem publishing 2 years ago
LICENSE.txt bundler-style gem publishing 2 years ago
README.md add Domino.find! method which waits for matching node 5 months ago
Rakefile clean up test tasks 2 years ago
domino.gemspec Version 0.6.0: Domino.find! 3 months ago

INTEGRATION TESTING DONE RIGHT WITH EMBEDDED MONGODB


INTEGRATION TESTING DONE RIGHT WITH EMBEDDED MONGODB

Introduction

Unit testing requires isolating individual components from their dependencies. Dependencies are replaced with mocks, which simulate certain use cases. This way, we can validate the in-test component behavior across various external context scenarios.

Web components can be unit tested using mock business logic services. Services can be tested against mock data access repositories. But the data access layer is not a good candidate for unit testing, because database statements need to be validated against an actual running database system.

Debugging a Production Server – Eclipse and JBoss showcase


Debugging a Production Server – Eclipse and JBoss showcase

Do you write code that has bugs? No, of course not. For the rest of us, mere mortals, who do write code with bugs, I would like to address a very sensitive issue: debugging an application that runs on a production server.

So, your application is ready for deployment. Unit tests were all successful, testersfound some minor bugs that were immediately fixed, the integration tests with the other department’s modules went pretty smoothly, the QA department made no complaints and the UATs were passed with flying colors. Thus, your awesome code is now up and running on the production server.

When the unthinkable happens. Your client notices some buggy behavior on the application and some of his customers have already started complaining. It seems that some nasty little bug has managed to get through all the testing procedures and make it to the live system. The client’s users pressure the client, the client managers pressure your managers and, guess what, your managers start pressuring you.

You start up the test server and try to reproduce the bug. Alas, everything runs correctly on the test server, so it might be a strange configuration issue or an edge case that causes the problematic behavior. The bottom line is that you cannot track the bug down using your testbed.

What a poor developer should do? Debug the application that runs on the production server. Note that this should be considered as a last resort and when all other attempts to spot the bug have failed. Be sure that the slightest wrong move while on production server (which serves a large number of users) could massively affect the application and cause even bigger problems or a complete service outage.

So, if you decide to take the risky road, read along on how to do it. Some basic guidelines before you get started. First of all, let your client know that you will connect to the production system and “perform some checks”. You don’t have to be specific on what will be done, but certainly don’t do anything without informing the client. Second, pick the time where real traffic is as low as possible. This is a no-brainer, you want as little as possible users to be affected, plus you don’t want to have the server running on heavy load. Third, be careful and try not to be hasty. There might be pressure, but take your time, it will be easier to track down the problem.

I will use JBoss AS and Eclipse in order to provide a hands-on example on how to perform the debugging. We will simulate a running application by deploying a simple piece of code on JBoss and executing a specific method. In most Java based application servers it is just a matter of configuration to start up the JVM with remote debugging enabled. Then, you use your favorite IDE, in my case Eclipse, to attach a debugger on the server’s port and start debugging. Note that enabling the remote debugging brings a small performance penalty, but I usually prefer to have the debugging option enabled so that I can connect to the server at will. In a different case, a JVM restart, thus a server restart, would be required in order to apply the new settings.

First, let’s create the code that will perform the debugging on. We will use a Java MBean which gets deployed on JBoss and has a predefined lifecycle. MBeans are managed beans, Java objects that represent resources to be managed. JBoss actually provides an implementation of an MBean Server, thus MBeans can be deployed on it.

The simplest way is to extend the ServiceMBeanSupport abstract class and implement a service that conforms to the ServiceMBeaninterface. First we create an Eclipse project named “SimpleMBeanProject”. Then we create an interface that our service will have to implement. The source code is:

Writing Tests for Data Access Code – Don’t Test the Framework


Writing Tests for Data Access Code – Don’t Test the Framework

When we write tests for our data access code, should we test every method of its public API?

It sounds natural at first. After all, if we don’t test everything, how can we know that our code works as expected?

That question provides us an important clue:

Our code.

We should write tests only to our own code.

Writing Tests for Data Access Code – Unit Tests Are Waste


Writing Tests for Data Access Code – Unit Tests Are Waste

A few years ago I was one of those developers who write unit tests for my data access code. I was testing everything in isolation, and I was pretty pleased with myself. I honestly thought that I was doing a good job.

Oh boy was I wrong!

This blog post describes why we shouldn’t write unit tests for our data access code and explains why we should replace unit tests with integration tests.

Let’s get started.