Going multi-platform: Running the tests from MacOs and Linux
Just a quickie tonight. Part of the reason for writing anything in Java is its ability to run on many devices. Before I move on from Java to dotnet and C# there are a couple of things to complete. In principle it should be no problem to call gradle to run my tests on both Linux and Macos. I’m going to cheat a little with Linux by running on Ubuntu on the Windows Subsystem for Linux. While we are at it, Microsoft make it very clear that this is not intended to run a Graphical User Interface. Of course I had to try it, and I can confirm, whilst you CAN run a UI. Don’t bother. If you really want the UI experience on your Windows machine add a VM. On WSL it is painfully slow. So on to the point of this:
Running the tests on Macos
Pre- requisites:
- Install a Java Virtual Machine. (I used the official Oracle one)
- A copy of the source code
My first attempt was not successful. It seems that MacOs doesn’t resolve the windows machine name.
So first thing was to replace this with the IP address, and then realise that it really isn’t something you want wired in to the code. I definitely need to pull that out into a configuration setting.
Then off we go: Navigate to the base of the source and type ./gradlew check
And there we go. That was configured to use Chrome on Windows as it is a pain to have a browser test running on the machine you are using. Awesome!
The warnings by the way are because I installed JDK version 9 which doesn’t like some of the reflection that various of the libraries use.
Running the tests on Linux (Ubuntu WSL)
So switching to using Linux, this time back on my development laptop. The same process as above, but being on the same machine I can access my regular source repository and run it from there with the same command.
And finally. Here you go, the results when running on Linux, connecting to a grid hosted on Windows 10 calling Chrome on MacOs. That’s pretty cross platform.
That’s a success in my penultimate post on Java. Next time looking at how to move the grid URL to the configuration file where it should be. This is not as simple as you might think.
Progress made:
- Tests running from the shell under both Linux and MacOs. I’ll leave it to my users to make it run locally if required.
- This has set me a high bar for my .net platform, support .net core and get it running on MacOs and Linux.
Lessons learnt:
- It’s good to know that planning to be multi-platform can pretty much, just work.
- Remember to ensure that all configuration is set through configuration files and environment, not hard coded.