Identifying and avoiding Tautological tests in Ruby on Rails applications

Writing unit tests is more of an art than a skill, and understanding what to test for comes with experience and/or mistakes. We look for the percentage of test coverage for examining the health of an application. However, the "coverage percentage" might be misused or overlooked. In particular, it falls victim to Goodhart’s law, which says: “When a measure becomes a target, it ceases to be a good measure”. Whenever we start writing test cases for the sake of improving the code coverage, we miss the whole point of testing and rather introduce Tautological Tests - poorly designed

Interesting feature of Elixir: Documentation as Tests

One of the coolest feature I came across in Elixir - our code documentation becomes our unit tests. I was amazed by its simplicity when I saw it in action in sample app I was writing. I feel this is one of the most incredibly and helpful feature I saw in any modern programming language in recent times. (Python has similar functionality using Python’s doctest.) Let me explain this by giving a quick demo using few simple examples: Math functions sum and multiply. Lets say this is our Maths module defmodule Maths do def sum(num1, num2) do num1

Configuring database_cleaner

Recently I added few integration tests in my projects using Capybara and Selenium webdriver and ran into banging my head against inconsistencies with test database. I create some records in test DB which were completely invisible to Selenium-driven browser-based tests. The problem is: the tests are being wrapped in database transactions, so any code running outside the actual test process (like, say, a server process servicing a Selenium-driven browser request) does not see the database records. Here are the steps to fix this problem - First of all, and this is very important, go into spec/spec_helper.rb and

Using Selenium IDE

What is selenium IDE: Selenium-IDE (Integrated Development Environment) is a tool that you use to develop your Selenium test cases. It’s a Firefox plug-in. The 'record' button in selenium IDE enables user to record his actions and is a real time saver. Although, many-a-times, due to the external plugins used in our app, we need to manually write scripts or atleast modify the recorded scripts. Why should developers know about selenium IDE? In many of our applications, we have multiple forms and features that require testing/checking whenever we make slightest of change in our code. Selenium IDE provides

Basic Security Testing Tips

1) URL manipulation through HTTP GET methods: The tester should check if the application passes important information in the query-string. This happens when the application uses the HTTP GET method to pass information between the client and the server. The information is passed in parameters in the query-string. The tester can modify a parameter value in the query-string to check if the server accepts it. Via HTTP GET request user information is passed to server for authentication or fetching data. Attacker can manipulate every input variable passed from this GET request to server in order to get the required information

How to Perform Load Testing?

Step 1 - Identify Objectives The purpose of this step is to identify and write the performance objectives of your application. The key question you should ask yourself is: “How should my application behave under load?” The main parameters we should consider are: Response time- The time that would take the application to display a certain output or perform a certain calculation. Example: the product catalog must be displayed in less than 3 seconds. Throughput– The rate of successful message delivery over a communication channel. Example: the system must support 100 requests per second. Resource utilization- A frequently overlooked aspect,

Selenium Best Practices

1) Use Robust object identification methods: Preferred selector order: id > name >css>xpath To locate an element we can use • the element’s ID e.g- driver.findElement("LinkId")).click(); • the element’s name attribute e.g- driver.findElement("LinkName")).click(); • by CSS statement e.g- driver.findElement(By.cssSelector(“a#LinkId”)).click(); • the element’s CSS statement e.g- driver.findElement(By.css("LinkName")).click(); • an XPath statement e.g- driver.findElement(By.xpath([//div 2/a[text()=’LinkText’]")).click(); • by a links text e.

Jmeter Best Practices

1) Do not use the Console to create your load: You can use the console for debugging purposes or to run a small load from it to make sure the script is running correctly. The GUI consumes a lot of memory under heavy load; therefore the console server by itself cannot sustain a heavy load. 2) Use the remote servers to create the load: Use the “Remote Start All” or “Remote Start” individual servers. 3) Limit the number of threads per engine to 300: This means the total number of threads generated by your test plan should be less than

How to do Performance Testing.

Performance Testing Process Below is a generic performance testing process 1. Identify your testing environment i.Know your physical test environment, production environment and what testing tools are available. ii. Understand details of the hardware, software and network configurations used during testing before you begin the testing process. That will help testers create more efficient tests. It will also help identify possible challenges that testers may encounter during the performance testing procedures. 2. Identify the performance acceptance criteria – i. This includes goals and constraints for throughput, response times and resource allocation. ii. It is also necessary to identify project success

Data Driven script with WebDriver

Example Testcase: Create a script to check login functionality of Gmail. Steps followed: 1) Open Google. 2) Click on Sign in 3) Enter Username and Password. 4) Submit Creds. 5) Check if the user is Signed In Script: import; import; import; import; import java.util.concurrent.TimeUnit; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import; import; import; import org.junit.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;