Skip to main content

Unit Tests

·

The Simulator is tested using an extensive unit test framework. The Framework tests the mathematical libraries, the simulator core as well as the graphical user interfaces for Android and PC.

Problems with the old unit tests #

Test where originally done with ScalaTest but are now performed using Kotlin and Hamcrest. While ScalaTest is the more powerful and readable test framework this comes at a price:

  1. Build: Building Scala with Maven or IntelliJ IDEA where cumbersome — especially when it came to the javadoc, side and deploy tasks.
  2. Debug: Debugging Scala code is extremely difficult as many things happens behind the scenes. Debugging Kotlin in IntelliJ IDEA works seamless.
  3. Updates: After each Scala language update it was a mayor hassle to get your code to compile again. In the end the project was stuck at Scala 2.12 as the update to 2.13 or 3.3 proved to work intensive. Kotlin update on the other hand where always worked hassle free.
  4. Java: Scala is dependent of a certain Java version. So not updating Scala is not a option either as you are stuck with an old Java as well. For Android projects a no go as they need Java 11. This resulted in an ugly build system where OS independent part was build with Java 8 and Android code with Java 11.
  5. Android: The Scala runtime is quite large making installation on Android difficult so I only ever used Scala for unit tests. Which is now an advantage making migration away from Scala that much easier.

Current status #

With Google moving from Java to Kotlin it was clear that Scala had no future in Android development. With the help of Vim and a home-made Scala to Kotlin Converter all ScalaTest code was converted to Kotlin and Hamcrest.

The conversion is an important milestone as working unit test framework makes bug fixing that much easier as unit tests make both repeating the issue and debugging a lot easier. Currently, the simulator and emulator has 1916 tests most of which are OS and GUI independent freeing the developer from cumbersome GUI interactions.

OS independent Desktop Android Total
Mathematical Library 607 N/A N/A 607
Other Libraries 0 7 0 7
FX-602P Simulator 446 1 89 536
FX-603P Simulator 613 2 92 707
RPN-45 Emulator 3 3 53 59
Total 1669 13 234 1916

Future outlook #

With the unit tests updated the project can now move on the bug fixing and updating the desktop GUI. The project can also move to more modern Java versions and maybe even move the main code to Kotlin. Since Kotlin is available on iOS this might also make an iOS version of the Simulator possible.