Question

I use the AAA syntax (Arrange, Act, Assert) in all my automatic tests (Unit tests, system tests, etc). Recently I started to write Coded UI tests. Now I wonder whether AAA syntax fits here. Unlike unit tests, where each test has one act and assert (or more than one assert) and I can have hundreds of them which will run less than couple of minutes, the Coded UI tests will run much longer. So if I write coded UI tests the same way I write my unit tests it will take them couple of hours (if not longer) to run.

If I compare Coded UI tests with manual UI tests then the menual tests don't use the AAA syntax in order to save time (not doing the same 'Arrange' action over and over just to check a field's value after another click).

What do you do in your apps? how do you recommend write Coded UI tests?

Was it helpful?

Solution

Yep. Use the same approach here also. A manual tester does a lot of verification in a single test. When automating it is better to split the multiple verifications test case to smaller test case and do minimum assertion per test case only. This will make your test case maintenance easy in future. Its not a good practice to proceed with another set of AAA once you have already done an Assertion in a test method.

Time is not an issue. UI automation is supposed to run slow. CodedUI tests are usually run on test lab having test controller and test agents. Here your hundreds of test will run in parallel on all test agents, thus reducing the overall execution time.

My CodedUI test method goes like this:

[TestMethod]
public void VerifyWhenThisThenThis() 
{
   // Prepare test data, Perform prerequisite action

   // Do test

   // One or more assertions to verify one major requirement only. 

   // If other major verification exist then split the test case 
   // and write a new test method for it.
}

If test case is huge then ask the manual tester to split it(or split it yourself informing the tester). Maintain a separate automation test pack having short test cases than the one manual testers have.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top