Test-Driven Development (TDD) Shines with Mocking

The article presents a perspective and some code samples on how one could some cool stuff with Test-driven development (TDD) and Mocking. The code samples are done in Java. Lets briefly understand what is TDD and mocking? What is TDD? Test-driven development, simply speaking, is a software development process in which developers write tests first and, then writing enough code to pass those tests. Once all of the tests pass, they do code refactoring to enhance code quality. Following are key advantages of adopting TDD as your development process: Enforces the developers to thoroughly think through various different test cases which could be used to test the functional/business requirements. It, …

Continue reading

Posted in Unit Testing. Tagged with , .

Law of Demeter Coding Violations & How to Fix Them

The article lists down Law of Demeter Violations and presents solutions on how to fix them. The code samples are written in Java. Feel free to share your comment, if any. What is Law of Demeter Principle? There are several good pages on the web which could be read to understand the object-oriented principle, Law of Demeter. Following are some of them: Demeter: It’s not just a good idea. It’s the law. Object-Oriented Programming: An Objective Sense of Style PMB Coding Violations The group of programmers working on a Demeter system, back in 1980, came up with this programming principle which they termed as Law of Demeter. According to them, …

Continue reading

Posted in Software Quality. Tagged with , .

Unit Tests – Mocking vs Stubbing Vs Spying

The article lists down some good reads (from different webpages on internet) on unit testing concepts such as mocking, stubbing and spying and represents summarized information on these concepts. Mocks Aren’t Stubs What’s the difference between a mock & stub? Mocking vs. Spying in mocking frameworks Mocking and stubbing in Ruby on Rails What’s the difference between faking, mocking, and stubbing? After going through all the above pages, I could arrive at following definitions: Mocking Mocking is a unit testing phenomenon which is used to replace real objects with test objects that mocks the behavior. These test objects are called as Mock objects. The point to note is that mock …

Continue reading

Posted in Unit Testing. Tagged with .

Top 5 Unit Testing Best Practices

The article lists down top 5 unit testing best practices that one could adopt to be able to write great unit tests with greater code coverage. Test-Along, if not Test-Driven Many a times, rookies have been found to start writing unit tests once they have written most of the code, e.g., towards the end of the coding. However, to make the most of unit tests, one should write them as they write the code. This is somewhat different and less difficult than writing tests first and code later as in test-driven development (TDD). Following are some of the advantages of doing “test-along” development: One could achieve greater code coverage by …

Continue reading

Posted in Unit Testing. Tagged with .

Junit & Mock Framework Mockito Code Samples – Part 1

The article represents code samples for Junit tests and Mockito, a mocking framework. In addition, it describes different aspects of unit testing and mocking. Software Requirement The goal is to create a simple piece of software which caters to the requirement of school admission where in applicants submit their admission application.   Class Design & JUnit Tests To meet above requirement, following different component is designed: Core Components (Key Ones) AdmissionApplication.java: Consists of method recordNewApplication which validates the submitted application, and later, stores in the database after successful validation. ApplicationValidation.java: Consists of methods for validating business rules associated with admission such as mandatory inputs (first name, last name, class, gender, …

Continue reading

Posted in Unit Testing. Tagged with , .

JUnit Tests Code Samples for Testing Exception Scenarios

The article presents an example of unit tests which tests both happy path and exception scenario. Business Requirement User trying to open an account must be validated against the business rules related with users’ registration. Following are different business rules: User must provide a valid email address User must provide his first name User’s age must be 18 and above   Class Design To demonstrate the unit tests with happy and exception scenarios, following classes have been shown below: SignupValidation: Consists of code validating business rules SignupException: Custom exception representing Signup business rules failure EmailValidator (Get the code from this page). SignupValidationTests: Unit tests for testing signup validation code Class …

Continue reading

Posted in Unit Testing. Tagged with .

Unit Tests – An Alternate Functional Requirements Documentation

The article presents a perspective on how unit tests could be written in a way that they could be used as an alternate form of documentation for understanding functional requirements. Many a times, it has been found that developers, primarily rookies, did not have a clarity on how to name unit tests. Thus, many of them have been found to name the unit tests such as testXXX where XXX is name of the method which they wanted to tests. There has been many recommendations on how to name unit tests, some of which are following: Given…When…Then… Check the page by Martin Fowler (http://martinfowler.com/bliki/GivenWhenThen.html) WhenXXX_ExpectYYY Names representing different use case scenarios …

Continue reading

Posted in Unit Testing. Tagged with .

Mobile Testing Tools & Methodologies used @ Expedia

The article lists down tools & methodologies used for testing Expedia mobile apps (both mobile web & native). Test-driven Development (TDD) TestNG: TestNG is a unit testing framework similar to JUnit. Apart from unit tests, TestNG can also be used to cover other categories of tests such as functional, end-to-end, integration etc. EasyMock: It is, primarily, used for mocking and custom solution for stubbing. As a mocking framework, EasyMock provides mock objects for interfaces by generating them on the fly using Java’s proxy mechanism.   Automated Acceptance Testing Frank (iOS): Frank, primarily, allows you to write and execute automated acceptance tests (using Cucumber) against your iOS application to verify its functionality. Simply …

Continue reading

Posted in Mobility, QA. Tagged with , , .

Tea-Time Java Quiz #1

Interview questions

Tea-Time Java Quiz is intended to be quick 5 questions Java quiz which one could quickly take from time-to-time to test their Java knowledge on the ongoing basis. [WpProQuiz 2]

Posted in Java. Tagged with .

Content Framework for Lunch & Learn Sessions on IT Applications

The article represents a framework using which one could plan their content for taking an introductory session on their applications. The primary objective of such presentation is to provide the audience with following information: Business overview Applications overview The proposed framework aims to satisfy the education needs for different stakeholders including delivery manager, project manager, development & testing teams. Presenters talked differently In my recent experience, I attended a series of sessions taken by leads of different project teams working for the same customer. Except for few of them, most of these sessions were not very interesting and audience enjoyed lunches more than the sessions. Following are some of the …

Continue reading

Posted in Software Engg.

APIs Performance Testing with Twitter Iago

The article talks about performance testing tool, Iago, which is created at Twitter for testing their core database interfaces, storage sub-systems and domain logic, up to the systems accepting front end web requests. Performance requirement of Twitter platform? Simply speaking, end users expect to read & post tweets with a very fast response time and, Twitter is expected to respond in that manner irrespective of load arriving at it with absolutely no room for any slowness, whatsoever. That is a tough one, isn’t it? This is unlike many enterprise business systems where users can be a little forgiving by waiting for the response to show up. So, they needed to …

Continue reading

Posted in Performance Engineering. Tagged with , .

Mobile Apps Testing Frameworks Used at LinkedIn

The article lists down tools & frameworks that are used for mobile app testing at LinkedIn. Vows: Vows is a behavior driven development framework for Node.js. It is used to do asynchronous testing with Node.js. The primary feature of the framework is its support for asynchronous testing with Node and, the ability to run concurrent tests. Vows also supports code coverage reporting. Robotium: Robotium is an Android test automation framework that has full support for native and hybrid applications. It supports black-box UI tests for android applications. It is used to test native LinkedIn android app. Selenium: Selenium is used to automate end-to-end testing with mobile web browsers. FoneMonkey: FoneMonkey …

Continue reading

Posted in Mobility, QA. Tagged with , , .

Lessons from Google on Distributed Storage System

The article lists down the lessons learnt by Google Engg. team while they implemented Google BigTable, a distributed storage system, which is used to manage structured data of more than 60 Google products or so. Read further about Google BigTable on this page. KISS Principle for Simpler Design & Coding With distributed systems bound to be complex and the related codebase expected to evolve over a period of time, it may be good idea to keep the design and coding simple for ease of code maintenance and debugging. One could apply the KISS principle by breaking down the problem into smaller pieces and do the design and coding appropriately. Read …

Continue reading

Posted in Distributed Systems. Tagged with , .

How to Measure Software Development Productivity

The article lists down pages/papers on measuring software development productivity. The Theory of Constraints: A good read on measuring software development productivity Measuring Productivity of Software Development Teams: The paper lists down different techniques/models for measuring software development productivity. CannotMeasureProductivity: Then, there is this article by Martin Fowler which says that it is difficult to measure software development productivity. He points about ineffectiveness of following approaches of measuring developer’s productivity: Lines of codes (LOC) Function points The software development teams working based on Waterfall model or Agile methodologies model tend to measure the developer’s productivity in terms of following variants: Function Points Story Points (size) vs Velocity Following pages present …

Continue reading

Posted in Software Engg, Software Quality. Tagged with .

List of Javascript Templating Engines & Why One Needs Them?

The article presents a short overview on why one needs Javascript templating engines and, a list of these frameworks. Please feel free to suggest one or more frameworks if I missed to include them in the list below.   Why do I ever need Javascript templating engine? Consider the following use-case scenario. Let’s say, you are a big enterprise with different line of businesses (LOBs). Each LOB has a set of web applications serving its business needs. With different LOB having different applications, following scenario is likely to happen: One particular LOB, X, has applications written with Java/JSP. Other LOB, Y, has applications written with .NET technology Other LOB, Z, …

Continue reading

Posted in Javascript, Web. Tagged with .

Why Facebook Relies on A/B Testing?

This article talks about A/B testing, why companies like Facebook rely on it and what would it take to adopt such testing for your website.   What is A/B testing? A/B testing is a strategy in marketing in which two versions, A and B, (the control and the treatment) are tested against each other. A/B testing, as the names implies, is a simple randomized experiment with two variants/versions, A and B, one of which version A might be currently used version (control) and, version B (treatment) is modified in some respect to study/test the users’ behavior. These tests are also called as split tests. These tests involve modification some of the following …

Continue reading

Posted in QA. Tagged with , .