A little rough application of image similarity algorithm--gui test

Source: Internet
Author: User

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);
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.