Why Tests should be run via CMD?

3–4 minutes

In today’s software development landscape, the need for efficient and effective testing methodologies has never been more crucial. Automated testing offers a powerful solution to streamline the testing process, providing rapid feedback and ensuring the robustness of applications. However, leveraging automated tests via the command line has emerged as a valuable practice for several reasons. This article explores the significance of running automated tests through the command line interface (CLI) and highlights its relevance in modern software development workflows.

There are a few reasons why we can need to run our automated tests via the command line. First, not all the members of your team can have IDE that supports all the selected tools installed. Let’s imagine a situation if a developer is doing massive refactoring and is going to see that his or her changes do not break the main functionality of the application. This is time-consuming to deploy the changes to your test environment, and to wait until your smoke suite passes. It is much faster to run your tests locally to identify the possible issues after deployment and to make everything to minimize the risks of critical and blocking defects on test environment. If you cannot run the tests via CMD, the developer will have to install your favorite IDE on the local machine and to run the tests via it. These are redundant actions if the tests can be run with the test automation framework cloned to the developer’s machine. So, running tests via CMD can be useful if developers want to launch automated test on their local machines.

The second case when it will be useful for you is when your project should have a CI process setup. For instance, you want to run all your automated test each night to receive constant feedback from your tests and keep them up to date. You are provided with a CI build agent and your requirement is to launch tests with the minimum set of setup actions required from DevOps side. For example, to launch our API tests you need JDK, and Gradle setup on the machine. And again, as in the situation when developers need to run tests locally, you are not allowed to setup Intellij IDEA or something like this on the build agent. In this case, the tests could be run only via command line. As a result, we see that running tests via CMD are must have to include automated tests into your CI process.

Finally, running tests via CMD can help to make your own automated CI pipeline for the web application deployment. Let’s imagine that your application is deployed on the test environment after each commit from developer. According to the best practices of automated testing, smoke suite of API tests should be run after such a deployment on the test environment. If you do not want to wait until each new deployment finishes most of your working day to start automated tests run manually, you should automate the process of tests start. This can be done only via trigger on your CI agent, which in its turn understands only commands represented as console commands. So, to make the deployment process of your web application’s API fully automated, you should be able to run the tests via command line.

In conclusion, the utilization of the command line interface for running automated tests presents a valuable approach in modern software development practices. By enabling seamless integration, accelerating feedback loops, and supporting automated CI pipelines, CLI-based testing enhances the efficiency, reliability, and quality of software development processes. Embracing this practice empowers development teams to streamline testing efforts, foster collaboration, and deliver robust, high-quality software products in today’s dynamic and demanding technological landscape.

The future of Testing®