Blog about testing & tech articles
subscribe via RSS
Blog articles | Continuous Integration | Tech tips |
-
Have you ever used Ruby's Object#method?
Object#method
is a little-known, yet very interesting Ruby method. Let’s see how it works and how you can use it in your code. -
Estimate database connections pool size for Rails application
Configuring the database connections pool for the Rails app might not be a straightforward task for many programmers. There is a constraint of max opened connections on a database level. Your server environment configuration can change in time and affect the number of connections to the database required. For instance number of servers you use can change when you autoscale it based on the web traffic. It means that the number of web processes/threads running for Puma or Unicorn servers could change. All this adds additional complexity. When you use two databases (e.g. Postgres + Redis), everything gets more complex. In this article, we will address that. You will learn how to estimate needed database connections for your Ruby on Rails production application.
-
Querying single columns in Rails Active Record using the #pluck method
Have you heard of the #pluck method from Rails’ Active Record? Read on to see what it does and how it can be used to easily query single columns from your database!
-
How BitBucket Pipeline with parallel Cypress tests can speed up CI build
Do you use BitBucket Pipeline as your CI server? Are you struggling with slow E2E tests in Cypress? Did you know BitBucket Pipeline can run parallel steps? You can use it to distribute your browser tests across several parallel steps to execute end-to-end Cypress tests in a short amount of time.
-
Using Ruby's 2.7 new #tally method
Ruby 2.7 introduced the
Enumberable#tally
method. It allows to easily count elements’ occurrences in a given collection. In other words, it literally tallies them up. :) -
How to run Ruby on Rails tests on Github Actions using RSpec
Are you thinking about migrating a Ruby on Rails project CI pipeline to Github Actions? You will learn how to configure the Rails app to run RSpec tests using Github Actions.
-
Run Minitest on Github Actions with parallel jobs using build matrix
How to run Ruby on Rails tests in Minitest on Github Actions? What to do if tests are slow? How to manage complex workflows? You can use Github Actions build matrices to divide Minitest files between jobs and run the test suite much faster.
-
Fix: 'warning: Using the last argument as keyword parameters is deprecated'
Have you encountered the
warning: Using the last argument as keyword parameters is deprecated
message in your Ruby project? You probably started seeing this after upgrading your project to Ruby 2.7. This version introduced the deprecation as a means to prepare users for a breaking change in Ruby 3. Let’s learn how to fix this! -
How and when to use Ruby case statements
Using the
case
expression in Ruby is a great way to write conditionals in a clear, and succinct way. Despite that, it’s not hard to encounter convolutedif
constructs in places where refactoring to thecase
statement would result in huge improvements. Let’s learn more about thecase
expression and when it’s best to use it. -
How to load Ruby gems from cache on Github Actions
How to start CI build faster by loading Ruby gems from cache on Github Actions? You can start running your tests for a Ruby on Rails project quicker if you manage to set up all dependencies in a short amount of time. Caching can be helpful with that. Ruby gems needed for your project can be cached by Github Actions and thanks to that they can be loaded much faster when you run a new CI build.
-
Faster Cypress + RSpec test suite for Rails apps on GitHub Actions using Knapsack Pro
Cypress is an amazing tool for end to end testing Rails applications, but large test suites can quickly take upwards of 20 minutes to run. That’s where Knapsack Pro comes in. Knapsack Pro Queue Mode to intelligently split your test suite into jobs that can be run in parallel, reducing run time to only a few minutes. In this article we’ll show how to quickly implement Knapsack Pro Queue Mode to speed up both Cypress & RSpec test suites in a Ruby on Rails app on Github Actions
-
Auto-scaling Buildkite CI build agents for RSpec (run parallel jobs in minutes instead of hours)
If your RSpec test suite runs for hours, you could shorten that to just minutes with parallel jobs using Buildkite agents. You will learn how to run parallel tests in optimal CI build time for your Ruby on Rails project. I will also show you a few useful things for Buildkite CI like:
-
Understanding and using Ruby's powerful #grep method
Ruby is known for its many handy methods. I’d like to take a look at one that is a little bit less known, but quite powerful nonetheless: the
#grep
method. -
Run Jest tests on GitHub Actions with optimal parallelization
Jest is a powerful testing framework used in JavaScript projects. Besides vanilla JS, it’s often used for React, NodeJS, Angular or Vue.js projects, among others. I am going to help you configure running your Jest test suite on GitHub Actions. We are going to use CI parallelization with Knapsack Pro, for maximum effectiveness. Let’s begin.
-
Cucumber BDD testing using Github Actions parallel jobs to run tests quicker
Cucumber employs Behavior-Driven Development (BDD) for testing your application. This type of test is often time-consuming when running in the browser. You will learn how to run Cucumber tests on Github Actions using parallel jobs to execute the test suite much faster.
-
Faster pipelines with Knapsack Pro by parallelizing Cypress tests on GitLab CI
When the runtime of our build pipeline had reached 20 minutes on average for each commit on each Merge Request, we knew we needed a solution to speed things up. We wanted to optimize everything we could within the pipeline, a way of doing this was to parallelize our tests with Knapsack Pro to speed up our Cypress integration tests which would save us a sizable amount of time.
-
Setting up Knapsack Pro in your Ruby RSpec project
Knapsack Pro offers two modes for RSpec tests in your Ruby application: the Regular Mode and the Queue Mode. They differ in their approach towards dividing your test files between parallel CI nodes.
-
Best Heroku add-ons for Ruby on Rails project
After working for over 8 years with Heroku and Ruby on Rails projects I have my own favorite set of Heroku add-ons that work great with Rails apps. You are about to learn about the add-ons that come in handy in your daily Ruby developer life.
-
RSpec testing parallel jobs with CircleCI and JUnit XML report
You will learn how to run RSpec tests for your Ruby on Rails project on CircleCI with parallel jobs to shorten the running time of your CI build. Moreover, you will learn how to configure JUnit formatter to generate an XML report for your tests to show failing RSpec test examples nicely in CircleCI web UI. Finally, you will see how to automatically detect slow spec files and divide their test examples between parallel jobs to eliminate the bottleneck job that’s taking too much time to run tests.
-
How to build Knapsack Pro API client from scratch in any programming language
You will learn how to integrate with Knapsack Pro API to run parallel tests in any programming language for any testing framework. You will see what’s needed to build from scratch Knapsack Pro API client similar to our existing clients like
knapsack_pro
Ruby gem,@knapsack-pro/jest
for Jest in JavaScript, or@knapsack-pro/cypress
for Cypress test runner (also in JavaScript). -
Fix intermittently failing CI builds due to flaky tests in RSpec
Randomly failing CI builds can be frustrating. One run is green, another is red (with no changes in the code!). Disheartening. Let’s see what can be done with this.
-
How to merge SimpleCov results with parallel Rails specs on Semaphore CI
If you are running Rails specs on parallel machines with Knapsack Pro, one challenge you will run into is combining the code coverage results generated by SimpleCov.
-
How to build native integration with Knapsack Pro API to run tests in parallel for any test runner (testing framework)
Do you know that Knapsack Pro API can work with any test runner in any programming language?
-
How to run slow RSpec files on Github Actions with parallel jobs by doing an auto split of the spec file by test examples
Splitting your CI build jobs between multiple machines running in parallel is a great way to make the process fast, which results in more time for building features. Github Actions allows running parallel jobs easily. In a previous article, we explained how you can use Knapsack Pro to split your RSpec test files efficiently between parallel jobs on GitHub Actions. Today we’d like to show how to address the problem of slow test files negatively impacting the whole build times.
-
How to merge Cypress test reports generated by Mochawesome on Github Actions
Looking through CI logs to find out which of your Cypress tests failed can be time consuming and error-prone, especially when your tests are spread out across several machines. With the Mochawesome test report generator and Github Actions, you can easily generate a beautiful, easy-to-read report of your test run, which merges results from all parallel nodes.
-
How to speed up Ruby and JavaScript tests with CI parallelisation
When working on a larger project, you may struggle with the problem of an increasingly growing set of tests, which over time begins to perform slower on your continuous integration (CI) server. I had this problem while working on a project in Ruby on Rails, where RSpec tests on CircleCI took about 15 minutes.
-
URI.escape is obsolete. Percent-encoding your query string
Have you encountered one of those warnings in your Ruby 2.7.0 project?
-
How to run Cypress parallel tests on Codefresh CI server
When you work with end to end tests in Cypress you may notice they quickly get time-consuming for running the whole test suite. The more complex the project the more test cases you may end up with and this can take a long time to run - dozens of minutes or even hours.
-
How to use Codefresh CI parallel steps to run RSpec a few times faster for Rails project
Codefresh.io seems to be a very nice CI solution to work with if you are a Ruby developer. I’ve tested one of my projects on Codefresh to see how it allows running fast tests. Codefresh has a matrix feature that lets you run parallel steps for the CI build. In this article, you will see how to leverage Codefresh matrix configuration and Knapsack Pro client library for testing in parallel your Ruby on Rails project with RSpec test suite.
-
GitHub Actions CI config for Ruby on Rails project with MySQL, Redis, Elasticsearch - how to run parallel tests
You will learn how to configure Ruby on Rails project on GitHub Actions. This specific Rails project has MySQL and Redis database. There is also Elasticsearch service running on CI. If your project is close to that setup below GitHub Actions yaml configuration will allow you to run tests on GitHub CI server.
-
How to run RSpec on GitHub Actions for Ruby on Rails app using parallel jobs
GitHub introduced their own CI server solution called GitHub Actions. You will learn how to set up your Ruby on Rails application on GitHub Actions with YAML config file. To run your RSpec test suite faster you will configure parallel jobs with matrix strategy on GitHub Actions.
-
How to run parallel jobs for RSpec tests on GitLab CI Pipeline and speed up Ruby & JavaScript testing
GitLab CI allows you to run tests much faster thanks to CI parallelisation feature. You can run parallel jobs across multiple GitLab Runners. In order to do it, you will learn how to split tests in a dynamic way across parallel tasks to ensure there is no bottleneck in GitLab Pipeline. Thanks to that CI build can be run as fast as possible so your Ruby & JS tests can be finely fast.
-
Cucumber testing with Jenkins parallel pipeline to get down CI build time
Cucumber is a popular automation testing tool for Behaviour-Driven Development (BDD) but when you use it for some time in your work project then the amount of automated tests adds up and you can spend dozens of minutes to run your Cucumber test suite. Sometimes complex projects can have a few hours of execution time for the Cucumber tests. To save time and speed up your Cucumber builds on CI (Continuous Integration) you can use CI parallelization. In this article, you will see how to do it for Jenkins using Jenkins parallel pipeline.
-
Cypress parallel testing with Jenkins Pipeline stages
In this tutorial for JavaScript end to end testing, you will learn about Cypress test runner for UI automation testing and how to use it with Jenkins CI server. Cypress helps with frontend automation testing using headless browser or just regular browser. E2E tests often take a long time to run and for bigger projects, those type of tests can take dozens of minutes or even hours. To save developers time you want to load balancing Cypress tests across Jenkins parallel pipeline stages. Thanks to that you can run your 1-hour test suite in a few minutes.
-
Split RSpec tests with Jenkins Parallel Pipeline to run specs faster
Jenkins CI server has a declarative pipeline that allows you to set Jenkins parallel stages. You can use the stages to run them at the same time (parallel run) to execute your RSpec test suite in a few smaller faster chunks instead of one long test suite run.
-
How to run tests faster on Heroku CI with parallel dynos
Heroku provides a CI solution out of the box for teams. Heroku CI can run tests in dyno instance for your project. What is more interesting you can run parallel dynos as part of your CI build. This allows you to split tests on parallel dynos to complete CI build faster and save time.
-
CodeClimate and CircleCI 2.0 parallel builds config for RSpec with SimpleCov and JUnit formatter
How to merge CodeClimate reports for your RSpec test suite executed with parallel builds on CircleCI 2.0? You will learn how to run RSpec parallel tests for your for Ruby on Rails project using CircleCI and how to send test coverage merged from parallel jobs into CodeClimate. We will cover config examples for:
-
How to merge CodeClimate reports for parallel jobs (CI nodes)
If you run tests on parallel jobs (using CI parallelisation) you need to merge CodeClimate reports from each parallel job (CI node) into a unified report.
-
Run parallel jobs on Semaphore CI 2.0 to get faster CI build time
Semaphore CI 2.0 allows configuring your CI build task with parallel jobs. This way you can run simultaneously a few different commands that do not depend on each other. But we could also use parallel jobs to split your test suite across a few jobs and this way save time. I will show you how to speed up your CI build for Ruby or JavaScript project (Rails / Node project).
-
Handle invalid JSON payload in Rails 5+ API. Catch JSON parse error
When someone post invalid JSON payload to your Ruby on Rails URL endpoint then Rails crashes with 500 error. We could render nice message instead of the error. For instance if you have public API you may want to show reason of the error to explain to your API client why the request failed.
-
Jenkins Pipeline how to run parallel tests in your workflow stages
Jenkins Pipeline is a suite of plugins that allows creating simple-to-complex build stages for your testing environment on CI. We can use Jenkins Pipeline to run a few stages at the same time and thanks to that parallelize test suite across a few stages to complete tests faster.
-
How to run CodeShip Parallel Test Pipelines efficiently - optimal CI parallelization
When you use CodeShip as your CI server you can significantly increase the speed of your CI builds with Parallel Test Pipelines. Pipelines allow you to run multiple commands at the same time, for instance, you can split test suite across a few pipelines and complete the CI build much faster.
-
CircleCI 2.0 cache Ruby gems or npm dependencies
CircleCI 2.0 allows us to cache specific files or folders. We can use that to cache ruby gems installed with bundler and restore them when we will run another CI build. This way new CI build could run faster by using cached files from the previous build. This article shows you how to cache npm dependencies as well.
-
How to run parallel dynos on Heroku CI to complete tests faster
Heroku provides a CI solution out of the box for teams. They can run tests in dyno instance for your project. What’s more interesting you can run parallel dynos as part of your CI build. This allows you to split tests on parallel dynos to complete CI build faster and save time.
-
How to run Travis CI parallel jobs with build matrix feature fast
Travis CI allows you to run multiple concurrent jobs as part of the same CI build. They even allow for up to 200 parallel jobs for open source projects (the same for private repositories). You can leverage that using Travis build matrix feature to run your project way faster by splitting tests into many smaller jobs that will run a subset of your test suite.
-
Improve CircleCI parallelisation for RSpec, Minitest, Cypress
Maybe you use CircleCI parallelisation to run your test suite across multiple CI nodes but you noticed that some CI nodes take more time to complete tests than the others.
-
Run javascript E2E tests faster with Cypress on parallel CI nodes
Cypress test runner is a great alternative to Selenium in end-to-end testing space. When it comes to E2E tests they tend to grow with time and running them is slow and becomes time wasting or just coffee break for developers. ;)
-
Clean RSpec configuration directory structure for Ruby on Rails gems needed in testing
When your Ruby on Rails project is getting bigger your test suite as well. You need to test more of your business logic and sometimes you will use other gems that can help you with that. Most of the time you may need something like
database_cleaner
,capybara
for feature tests orrspec-sidekiq
to test your workers. -
How to run tests in Minitest continuously with dynamic test files loading
Recently I’ve been looking into the source code of Minitest to find out if I can run some tests and then dynamically run another set of tests once the previous run is done. This would allow me to provide dynamically a list of tests to execute on my parallel CI nodes to run CI builds faster.
-
How to export test suite timing data from Knapsack Pro API
Knapsack Pro tracks your CI builds and how long each test files took to run on one of parallel CI nodes. Thanks to that Knapsack Pro can prepare the optimal test suite split for your future test suite runs on your CI provider.
-
CircleCI 2.0 Capybara feature specs - Selenium webdriver with Chrome headless
I’ve been using Capybara-WebKit for a long time but while switching from CircleCI 1.0 to CircleCI 2.0 I had some problems to use it on the CI.
-
When distributed locks might be helpful in Ruby on Rails application
During this year I noticed 2 similar concurrency problems with my Ruby on Rails application and I solved them with distributed locks. I’m going to show you how to detect if your application might have a concurrency problem and how to solve it.
-
Auto balancing 7 hours tests between 100 parallel jobs on CI - Buildkite example
I like tests. You may like them too because thanks to them you are not afraid to change the code. Tests can help you catch errors earlier. I like tests, even more, when they are fast.