Because of some private matters, an article that was supposed to have been completed until today can be hastily settled. In the previous two articles, "C # Implementation and evaluation of the image similarity algorithm", the idea and practice of the unit test of "drawing line" (Draw a lines), has introduced a simple reading histogram algorithm and some testing ideas about GUI drawing. It is important to note that the most practical of the methods mentioned in the ideas and practices of unit testing for "drawing lines" (Draw a line) is that mock methods are not the subject of today.
This article continues with the previous idea of simply writing a little thought about GUI automation testing.
Problem
A solution for automated testing of functional applications for drawing lines, drawing, and so on?
Solving ideas
Take a screenshot of the use case of the output screenshot, the picture as the output, of course, before need a corresponding picture as expected results, in order to compare.
For an expected result picture, the way to do this is to run an automated test code to intercept a picture, and then manually check to see if the picture is the result of it, and then use the picture as expected. (In the functional automation test, the first time you run the automated test script, it should be done under the conditions of manual monitoring, and more often when we debug the corresponding script has done the work.) )
Sample code
1, sample code to be tested
Draw A Line
<summary>
Draw a graphic on a Windows window
</summary>
Class Draw_A_Line:System.Windows.Forms.Form
{
Private Form MainForm;
System.ComponentModel.Container component = NULL;
Pen mypen = new Pen (color.black);
Bitmap bmpimg = null;
Public Draw_a_line ()
{
InitializeComponent ();
}
private void InitializeComponent ()
{
This.component = new System.ComponentModel.Container ();
This. size = new Size (256, 256);
This. Text = "Testmainform";
}
<summary>
Clean up resources that are in use
</summary>
<param name= "disposing" ></param>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (component!= null)
{
Savebmp (); Save screenshot
Component. Dispose ();
}
}
Base. Dispose (disposing);
}
Static Graphics savegraph;
protected override void OnPaint (PaintEventArgs e)
{
Graphics g = e.graphics;
Mypen.width = 5;
G.drawline (Mypen, 16, 27, 38, 49);
}
}