This article presents just a demonstration of how we can start an automated test system development. It's open to all to contribute and make it more worthy. Also, kindly note that you will require both the ATS.zip and Testapp.zip.
I had been looking for an automated test system tool for quite some time, but could not find something which was reliable. So I thought why not try and develop something myself.
Using the code
The code can be used by anyone who has a basic understanding of the
Reflection namespace in the .NET framework. The sole idea is based on any other reflector available in the market, for example Reflector, or the ILDASM that ships with the installation of the .NET framework.
I have tried to use the same idea here. Most of the usable code resides in ATSMainForm.cs. Once we are inside the application:
static void Main ()
Application.Run (new ATSMainForm ());
We will need to select the target assembly/executable and hit on Launch. What we do in launch is shown here:
private void launchBtn_Click (object sender, System.EventArgs ea)
this.m_mainPnl.Enabled = true;
this.m_invokeMethodBtn.Enabled = false;
this.m_methodNameTxtBox.Enabled = false;
this.m_testAssembly = Assembly.LoadFrom (this.m_appPathTxtBox.Text);
Type types = m_testAssembly.GetTypes ();
MethodInfo entryMethod = m_testAssembly.EntryPoint;
this.m_testForm = m_testAssembly.CreateInstance (
ThreadPool.QueueUserWorkItem (new WaitCallback (RunApp), m_testForm);
catch (Exception ex)
Form errForm = new ATSError (ex);
The good thing about Reflection can be observed here. .NET Reflection allows you to list down all methods/properties/events/classes .. in fact, every thing that is related to this application.
Here is how:
private void AddMethods (int nodeRank, Type types)
MethodInfo methods = types[nodeRank].GetMethods (m_bindingFlags);
this.m_mainTv.Nodes[nodeRank].Nodes.ImageIndex = 2;
this.m_mainTv.Nodes[nodeRank].Nodes.SelectedImageIndex = 2;
this.m_tsStatus.Text = "Analysing Methods...";
this.m_tsProgressBar.ProgressBar.Maximum = methods.Length;
int nodeCount = 0;
for (int iMethodCount =0; iMethodCount < methods.Length; iMethodCount++)
this.m_tsProgressBar.ProgressBar.Value = (int) (iMethodCount/methods.Length * 100);
MethodInfo method = (MethodInfo) methods.GetValue (iMethodCount);
MethodAttributes methodAttrib = method.Attributes;
if ((method.DeclaringType.FullName == types[nodeRank].FullName.ToString ()) &&
!(methodAttrib.ToString ().Contains ("SpecialName")))
this.m_mainTv.Nodes[nodeRank].Nodes.Nodes.Add (method.ToString ());
this.m_mainTv.Nodes[nodeRank].Nodes.Nodes[nodeCount].ImageIndex = 2;
this.m_mainTv.Nodes[nodeRank].Nodes.Nodes[nodeCount].SelectedImageIndex = 2;
this.m_mainTv.Nodes[nodeRank].Nodes.Nodes[nodeCount].Tag = method;
this.m_tsProgressBar.ProgressBar.Value = 0;
Similarly, the events and properties/fields can also be listed. This is one of the approaches that can be followed to write your own reflector or ILDASM :)
Next, the user can start clicking on the method names by which the invoke method textbox is enabled/disabled and then we can invoke any method (say
button1_click) as demonstrated in testapp.zip.
Points of interest
An interesting point is the way the test is run. Right now, the method names are hard-coded, but later we might like to have these read from some Excel file or something and then use those method names instead.
- Modified the code a bit to have the start-up form input from the user. The name of the form will be its fully qualified name, i.e., NameSpaceName.FormName.
Check out the latest binaries. I'll upload the updated code and documentation very soon.