Site Loader
Auckland, New Zealand
Reason for TPL usage in Framework We are building a framework using Visual Studio 2010 Test in Coded UI testing. The performance and Speed of execution is good, since it leverages the power of C# as opposed to QTP which uses VB script. The way our Framework perform operation is this
  1. Performs Data entry operation in AUT UI
  2. Performs validation (Database query comparing App DB and Test DB) and reporting.
  3. Then perform the step1 once again for second scenario or test case.
We use the same method in many of our QTP based framework, which is slow, the reason behind, the code (Step 1) wait till the validation operation is completed, so that next UI entry operation can be done. Here the delay will be minimal or maximum depending upon the query for validation is being exercised. This delay sometimes makes the tester annoying to wait seeing their application UI doing nothing for long time, while validations are being performed behind the scenes. Hence I was thinking to devise a plan which makes UI entry and Validation in parallel (Not for the first testcase, since validation will fail if initial testcase and validation will run in parallel). Solution I was reading the new features of .Net 4.0, there I was struck with a topic which really interested me, that’s TPL which is Task Parallel Library, wow, that was awesome. To me that’s really interesting since it unlocked the problem which I was facing for sometimes. About Task Parallel Library TPL enhances multithreaded programming in two ways.
  • It simplifies the creation and use of multiple threads
  • It automatically make use of multiple processors, which means you can scale your application to make use of multiple cores of processors available.
TPL is defined in System.Threading.Task Library. The execution flow is shown diagrammatically. Fig.1 without using TPL The above picture illustrates how execution is being performed. UI entry is being done and then the process waits for validation and reporting to complete, then again UI entry starts its execution, which causes the delay in execution time. Fig.2 Using Task Parallel, running two processes in Parallel I cannot outsource the whole code but here is the code snippet which will best demonstrate how the code can be written and implemented in your framework. The above code while executed will give the result as shown below As you could see the execution is happening parallel for both UI and Validation. The above code is not the actual code which can be implemented for parallel processing, since its just an idea and example of how we can implement it in a very simple way by leveraging the power of TPL. For any queries and clarifications, please mail me @ or leave your comments in blog. Happy reading in

Post Author: Karthik kk

Leave a Reply

Your email address will not be published. Required fields are marked *