I’m going to share a short example of how I automated the testing of recent piece of work and share a few tips on how to use Minion.
When I picked up this piece of work I was tasked with refactoring and updating a large area of code related to the UI, presentation and data access of a calculator widget. The internals were already heavily covered by unit tests – so I was happy I would not break any of the calculation logic, but I did need to be careful that I didn’t feed the wrong data into these various modules and that I hadn’t crossed any wires so to speak.
Of course there are a number of ways of doing this – code based integration tests are fantastic, but for this example I thought I’d write a quick browser based test. The idea is that if I capture inputs and outputs from a UI perspective before I make any changes to the code I can quick validate that I haven’t broken anything.
Below is a test script, executed by Minion to test the calculator.
I didn’t have any way to distinguish textboxes (no unique classes, and dynamically generated Id’s by asp.NET). To work round this Minion can gather a group of elements:
i.e .calculationForm input returns an array of 2 inputs.
I can specify an index to determine which input from the group I want Minion to use as its context element – easy.
Another tip is that you could also use jQuery to achieve the same effect. The code:
Will do exactly the same thing.
INPUT .calculationForm input 1 “1”
INPUT .calculationForm input 2 “1”
SELECT .calculationForm select @100
CLICK .calculationForm .goldBtn
VERIFY .savingValue 1 “£716.84″
– OR VERIFY jQuery(‘.savingValue:eq(0)’) “£716.84″
VERIFY .savingValue 2 “£706.84″
VERIFY .savingValue 3 “£701.27″