Greetings, fellow testers. Last week I was asked a question about testing output, specifically if I could help with an example of a test verifying that a list in an application has been properly sorted. Asking QuestionsThis is actually a fairly common question, and is one that we cover in our documentation.

I mention it here for two reasons. In part to point out the example code section of Test Studio's online documentation, but mostly because the documented example is correct but in my opinion it’s only half of the story – the second half. The first thing I’d recommend is to make sure we’re actually testing the right thing; are we in the right section of the test pyramid?

In many cases, a website’s data is coming from some sort of back-end system — a database, normally. That data is being delivered by a stored procedure or other method. If that’s the case, and that sproc or method is doing the sorting, then testing it via the user interface is not the most efficient way. This is an excellent opportunity for a good set of unit or integration tests; tests that can run against the stored procedure or method itself, using on a large number of data sets and good edge cases without the overhead of the user interface. To go a step further, check to see what routines are actually being used to do the sorting — if for example the stored procedure is using the database’s native ORDER BY clause or a method is using a framework’s sort, ask yourself if that’s something you really need to be testing.

As more systems move to Ajax-style dynamic pages, it’s likely that your application actually is using the client side to do the sorting. It can be more responsive, if the data set is of a reasonable size, and provides the user a nicer experience. In this case, again, I’d see what method’s being used. If the developers are using a well-known control that has its own sort, we’re back to asking if that’s something we need to test repeatedly. If we don't trust the control we're using... why are we using it?

Finally, we get to the case where I would actually recommend testing via the user interface — an application in which your developers are using their own sort routine in browser-side code. Now it’s time to jump into that sample code found in the Test Studio documentation: Verify Sort Order in an HTML Table.


About the Author

picture of Steven Vore

Steven Vore

Steven Vore is an Evangelist for Telerik's Test Studio. He has worked in software support and testing for the better part of two decades, and enjoys exploring ways to make software easier to use. He is a fan of movies and music, and can often be found on Twitter as @StevenJV.

Related Posts


Comments are disabled in preview mode.