Wintellect Blogs

Unexpected Benefits of End-to-end Testing

Jonathan Wood

3 Jan , 2017  

End-to-end Testing

Testing where the entire application is tested in a real-world scenario such as communicating with the database, network, hardware and other applications.

The above is the general definition of what an end-to-end test is. Most of these tests are written to make sure general flows of the application that a user may take are working correctly and as expected. However, there are other benefits to running and writing these tests that may not be as well known.

Find bugs when writing tests

True, end-to-end tests are supposed to find bugs, but that’s mainly when you run tests that have already been written to make sure no bugs were introduced as the project is being developed on. However, there are a lot of bugs you can find when you’re writing end-to-end tests. In my experience, I’ve usually found an issue while writing an end-to-end test on a specific functionality that I’m testing.

Unit tests will do this, too, but end-to-end tests can find issues that aren’t always logical, such as UI issues and components not interacting as expected. This, to me, is probably the most useful thing about having end-to-end tests.

Find hard to detect issues

Applications depend on all components of the application interacting and working correctly.… Read more

Wintellect Blogs

Get Function Keys By Default with Parallels and a MacBook Pro Touch Bar

John Robbins

27 Dec , 2016  

Having purchased a 15 inch MacBook Pro with Touch Bar recently, I’ve been having a good time seeing how that Touch Bar can be used. With applications that know about the Touch Bar, it is an interesting UI approach. But with many macOS applications not having full Touch Bar support, I’ll reserve full judgment until most apps support it. I will say that the Photos app shows a tremendously useful way to use the Touch Bar.

One app I use all the time, the virtual machine program Parallels, does not currently support the Touch Bar, so whenever you are in it, you see the default Touch Bar view:

image

The only problem is that for Windows development, you really, really need those function keys. Sure you can press the FN key to have them come back, but I wanted the function keys to be the default. A little poking around in System Preferences, Keyboard settings, Shortcuts, showed the Function Keys section. I added Parallels Desktop to the list and, voila, now Parallels defaults to showing the function keys whenever Parallels has focus. Not the most earth shattering of tips, but one that certainly made my life better.

image

Now if only Apple would sell a Touch Bar external keyboard…… Read more

, ,

Wintellect Blogs

Top NPM Packages for Spectron Testing

Jonathan Wood

27 Dec , 2016  

Spectron is a great tool for testing your Electron applications. However, some help is needed to get the full use out of it. This post will go through all of the npm packages I’ve found useful in my Spectron testing.

Jasmine Reporters

The default reporter for Spectron is to just log out to the terminal. That’s great, but I like pretty colors in my terminal, especially when they’re green for success and red for error. That’s where the jasmine reporters package comes in. Actually, there are a few reporters in this package. Not just one for the terminal. In fact, I use two reporters from this package – the terminal reporter and the JUnit XML Result reporter.

Why do I use the second reporter? Well, that reporter plays very well with the jasmine-xml2html-converter package. This package converts the XML results from the JUnit XML Result reporter into an HTML file with graphs and a much easier way to view the tests.

Gulp

Yep, the package to have build tasks in your JavaScript projects has been useful for running Spectron tests. Whether you’re using Jasmine, Mocha, or Karma for your tests, there are gulp versions.

Something I’ve used that seemed to help is to break up your gulp tasks to run tests by scenario.… Read more

, , ,

Wintellect Blogs

Introducing the Spectron Command Line Tool

Jonathan Wood

21 Dec , 2016  

After some Spectron experience there tends to be some things that can get repetitive when creating Spectron tests. I figured creating a tool to do just that would be handy to have. So I created the spectron-cli npm package.

Granted, this command line tool doesn’t do all that much. Currently, it only has two commands to it.

The “init” command will create an e2e directory, if it doesn’t already exist in the current directory it’s run in. It will also create two files in that directory for you – a test.spec.js file and a test.page.js file. These files will include templates to help you get started writing your Spectron tests.

The “add” command will just create a spec file and a page file with the name of your choosing inside the e2e directory.

The way the templates are laid out, however, you would have to include chai and chai-as-promised packages if you don’t already have them. These tests can be run with mocha or jasmine test runners.

So feel free to install the tool with npm install spectron-cli and see how it works for you (or just find ways to break it). It is open source so feel free to submit and enhancements or fixes or just create an issue.… Read more

, ,

Wintellect Blogs

Spectron Tip: Getting Selectors From Chrome Dev Tools

Jonathan Wood

21 Nov , 2016  

If you’re using Spectron (or even Protractor) for automating your applications probably the most time consuming thing is to figure out exactly what selectors you need in order to interact with your application. Whether to click on a button or to test if the text of a dialog is what you expect, you need a selector in order to access it.

The Chrome dev tools are awesome for figure out what selectors you need by looking at the Elements section and manually going through the page and looking at all the classes and such that you may need in your tests. However, here’s a quick tip if you have a complicated item that you need to select in your tests.

Copying CSS or XPath

The Chrome dev tools has a pretty nifty way to select very nested or complicated items on your page where you can then use for your tests as selectors.

I’m at a page for the Electron documentation and have the dev tools pulled up.

 

devtools

Let’s say I need to select the require('electron') part of this page. Not the most trivial of selectors, but the dev tools can really help us out here. Right click on the element in the dev tools and you’ll see something similar to a Copy item.… Read more

,

Wintellect Blogs

Creating Page Files for Spectron Tests

Jonathan Wood

12 Oct , 2016  

Now that we’ve got Spectron working, let’s add some more to it to help with our testing. One way of doing end-to-end testing is to have a separate file that contains our page objects and any helper functions specific to that page. This will help the readability and maintainability of our tests. The latest code to this demo is located on GitHub.

Accessing Page File From Main Test File

Let’s create our page file. Since we’re in vanilla JavaScript, I’ll be using module.exports to export our file so we can access it in our main test file.

But first we need to declare a function and properties to export from a separate file.

var TestPage = function () {
  // Properties and functions relevant to the page here
}

module.exports = TestPage;

Here we have a file named test.page.js that will contain our page objects – properties and functions associated with our page that we will test against. We just create a main object, TestPage, and add all that we’ll need. To have it able to be accessed in our main test file we add the module.exports = TestPage line at the bottom.

From there we can now reference this file in our main test file:

const testPage = require('./test.page.js');

And then we can new it up to use it:

var page = new testPage();

Page File Properties

Now that we can access our page file from our test file, let’s add some value to it.… Read more

,

Wintellect Blogs

End-to-end Testing Electron Apps with Spectron

Jonathan Wood

5 Oct , 2016  

You’ve built a really awesome Electron application, but you want to include a few automated tests to make sure a regression doesn’t occur? Spectron is here to help!

Spectron is Electron’s end-to-end testing library. Let’s see how it we can set it up to use in our own Electron projects.

If you want to go straight to the demo code, the repository is on GitHub.

Setup

For this post and demo code I’ll be using Electron’s quick start repository. This repository has all that is needed to get a quick “Hello World” application going in Electron.

While the quick start repository has all dependencies that we need to run an Electron application, we need to add Spectron to it. This is just another NPM package to install:

npm install --save-dev spectron

To help with our testing and assertions we’ll also bring in a couple of more packages:

npm install mocha chai chai-as-promised

Our package.json file should now have the following dev dependencies:

"devDependencies": {
    "chai": "^3.5.0",
    "chai-as-promised": "^5.3.0",
    "electron": "^1.3.4",
    "mocha": "^3.0.2",
    "spectron": "^3.4.0"
  }

So we can save some keystrokes and make it a bit easier for us to run our tests, I added an NPM script to the package.json file to run our end-to-end tests with mocha.… Read more

, , ,

Wintellect Blogs

A Brief Tour of Azure IoT Hub

Josh Lane

29 Sep , 2016  

I’m preparing some material for a webinar on Azure IoT in mid-October (you are signed up, aren’t you?) and thought I’d do a quick intro to the basic concepts and moving parts.

Azure IoT Hub is a cloud-scale service for managing and securely communicating with large numbers of field devices (potentially millions at once); communication can occur from device to cloud, and also from cloud to device (for issuing commands or queries to devices). It’s standards-based so it works with many device types, a number of communications protocols and guest operating systems, and supports various network topologies. It also supports custom gateways for edge analytics, traffic optimization, etc. Finally, it integrates with a number of existing Azure services like Stream Analytics, Machine Learning, and Event Hubs to maximize scale and minimize time to insight.

Let’s walk through a sample Azure IoT Hub-based solution and see it in action. I live in Atlanta, GA USA and our public transit system provides geolocation and other metadata about buses and trains; we’ll use the bus data to simulate device activity in the field (each bus == a device) and use IoT Hubs, Stream Analytics, Azure Storage, DocumentDB, and some custom code to collect and present that data in a meaningful way.… Read more

, ,

Wintellect Blogs

Why can’t I use the “dynamic” C# keyword in Xamarin.iOS?

Keith Rome

23 Jul , 2016  

Occasionally I see this question pop up in various forms; usually an app developer has written some fairly clever code that relies on the dynamic keyword in C#. Their code runs swimmingly on every other platform—and it also compiles just fine for iOS. But when they run the app on a physical iPhone or iPad they see runtime exceptions… often in strange and unexpected places. Finally, the problem gets tracked back to usage of dynamic, but the question remains: “Why didn’t that work?”

Buried down in the Xamarin.iOS documentation, we can find a page that discusses the limitations of MonoTouch / Xamarin.iOS (https://developer.xamarin.com/guides/ios/advanced_topics/limitations/). On this page there exists some guidance regarding “Dynamic Code Generation” in which (among other things) it says that the Dynamic Language Runtime (DLR) is not allowed. OK, this seems related to the dynamic keyword, but you might be wondering how, exactly. The topic mentions that this is somehow due to the System.Reflection.Emit API not being available in iOS—but you clearly aren’t using that .NET feature, so what’s the deal?

Dynamic Code is not Allowed on iOS

Dynamic Code is not Allowed on iOS

It boils down to a security restriction in iOS. Apple does not allow apps to generate executable code at runtime, because this would be a potentially major security vulnerability.… Read more

, ,

Wintellect Blogs

Using XAML in F# Xamarin Forms – A Screencast

Jonathan Wood

1 Jun , 2016   Video

Now that we’ve seen the awesome new stuff in Xamarin Studio for F# let’s go a bit further and actually use some of those improvements to our advantage. However, instead of just a regular blog post, I thought it’d be worthwhile to do a screencast for y’all.

You can view the demo code directly on GitHub. Enjoy everyone!

 … Read more

, , ,