New languages and frameworks are always pushing the envelope when it comes to developing software applications. While older technologies may have well-established test automation tools, newer languages and frameworks may lack some of these features, making it challenging for developers to get up-to-speed with Agile best practices.
Let's take a look at how Electron apps are conventionally tested, as well as how to test them with TestComplete.
What is Electron?
In addition, the main process can access the native graphical user interface through a series of Electron modules, which makes it possible to interact with the underlying operating system. The only downside is that these applications involve more overhead than the purely native applications, which means that they may have a bit slower performance and some other limitations.
Testing With Spectron
The most popular testing framework for Electron is the built-in Spectron, which is built with ChromeDriver and WebDriverIO. The testing platform sets up and tears down your Electron application and allows it to be test-driven remotely with full support for Electron APIs, as well as compatibility with testing libraries like Mocha, Jasmine, AVA and Chai.
Continuous integration is a bit more challenging since it requires a display driver, which must be installed and configured to launch the application. For instance, Jenkins CI users must install the Xvfb plugin to add a display driver in order for the tests to run successfully. However, CircleCI and some others already have display drivers setup by default.
A typical Electron testing workflow with Spectron might involve developers writing unit tests in a conventional TDD fashion and then writing integration tests to verify that the acceptance criteria are met before approving a feature to deploy. Continuous integration servers might verify that all of these tests pass before they’re deployed into production.
Alternatives to Consider
SmartBear's TestComplete is an automated UI testing tool that makes it quick and easy to create, maintain and execute functional tests across desktop, web and mobile applications. With our AI-powered object recognition engine, TestComplete automatically finds dynamic UI elements quickly, easily and accurately — eliminating the need for code-based tests.
The dynamic nature of TestComplete transates to robust tests that don’t break when the user interface changes. TestComplete automatically switches its object recognition to leverage AI when application properties aren’t easily detected, enabling test engineers to capture UI elements at a contextual level and easily manipulate complex user actions.
TestComplete even makes it easy to incorporate behavior-driven development (BDD) into your workflow. Test cases that are designed and written in Gherkin syntax can be easily converted into automated UI functional tests and maintained with object recognition and record-and-replay technology without the need for additional plugins or integrations.
How to Get Started
TestComplete makes it easy to create automated tests for Electron applications since it automatically recognizes web pages that implement the application interface and individual web elements on those pages. Supported versions of Electron include 1.8.2, 2.0.2, 3.0.2, 4.0.2 and 5.0.0 and 6.0.0, although other versions could also work with the framework.
There are a few simple steps to get started:
- Select File > New > New Project and open the Create New Project wizard.
- Specify the project’s name and location.
- In the Project Explorer, double-click the testedApps node, right click, and select Add Application.
- Select Generic Windows application and specify the path to the Windows binary.
- Start recording a test by going to Test > Record > Record Keyword Test.
- Expand the Recording toolbar, click Run App, and then select the Electron application.
- Create Property Checkpoints by clicking Add Check. Checkpoints verify objects and values in the application that’s being tested.
- Click Stop on the Recording toolbar when you’re finished.
- Click Run Test on the Keyword Test editor toolbar to run each test.
The overall testing process works the same as any other web application since TestComplete automatically recognizes the web pages and components within Electron applications. In addition to basic keyword tests, you can run more advanced data-driven tests that simulate user actions with different input data to provide larger test coverage.
You can view a complete tutorial along with a demo application to test in the TestComplete documentation. Or, download a free trial of TestComplete and see how easy it is to get started testing your Electron apps in a hands-on way.
The Bottom Line
It can be challenging to test cutting-edge new technologies, like Electron, but platforms like TestComplete simplify the process by working at a higher level and in a way that's more accessible for test engineers and other non-developers. By making testing more approachable, many development teams find it easier to achieve more complete test coverage.
Download a free trial of TestComplete and see how easy it is to get started testing your Electron apps.