About software Testing (3): Extended applications based on the previous equivalence class partitioning

Source: Internet
Author: User

  

  

Overview of the Outlook: This article mainly for the previous topic to make some extensibility changes, resulting in equivalence class equivalence class changes. This way, the equivalent class partitioning method of adding up to 3 editbox is realized, which strengthens my understanding of equivalence class partitioning.

1, Title content: Write 3 editbox, ask EditBox to allow 1 to 6 English characters or numbers, press OK to end

Valid equivalence classes: Length: 1 to 6 characters: a-z,a-z,0-9.

Invalid equivalent class length: 0, 7 characters: English/numeric characters, control characters, punctuation.

2, about the equivalence class some necessary knowledge I will not repeat, the previous article has mentioned.

3. Dividing equivalence classes

numbering Valid equivalence classes numbering invalid equivalence class
1 Length of 1-6 6 Null
2 Number 0-9 7 Length greater than 6
3 Small Letter A-Z 8 English/numeric characters, control characters, punctuation
4 Capital Letter A-Z 9 N0.1 correct, N0.1 correct, N0.1 error
5 The correct number of inputs is 3 10 N0.1 correct, N0.1 error, N0.1 correct
11 N0.1 correct, N0.1 error, N0.1 error
12 N0.1 error, N0.1 correct, N0.1 correct
13 N0.1 error, N0.1 correct, N0.1 error
14 N0.1 error, N0.1 error, N0.1 correct
15 N0.1 error, N0.1 error, N0.1 error

4. Test Cases

numbering Test Cases overriding equivalence classes Expected output
1 3a4b5c,3a4b5c,3a4b5c 1,2,3,4.5

No.0:ok
No.1:ok
No.2:ok

2 123,123,null 6,9

No.0:ok
No.1:ok
No.2: input cannot be empty

3 123,123,1234567 7,9

No.0:ok
No.1:ok
No.2: Input character length too long

4 123,123,[email Protected]#¥ 8,9

No.0:ok
No.1:ok
No.2: only English letters or numbers can be entered

5 123,[email protected]#¥,123 10

No.0:ok
The most: You can only enter English letters or numbers
No.2:ok

123,[email Protected]#¥,[email Protected]#¥ 11

No.0:ok
The most: You can only enter English letters or numbers
No.2: only English letters or numbers can be entered

7 [Email Protected]#¥, 123,123 12

no.0: Only English letters or numbers can be entered
No.1:ok
No.2:ok

8 [Email Protected]#¥, 123,1234567 13

no.0: Only English letters or numbers can be entered
No.1:ok
No.2: Input character length too long

9 [Email Protected]#¥, 1234567,123 14

no.0: Only English letters or numbers can be entered
Maximum: Input character length is too long
No.2:ok

10 [Email Protected]#¥, 1234567,null 15

no.0: Only English letters or numbers can be entered
Maximum: Input character length is too long
No.2: input cannot be empty

5. Write code

    

Import java.awt.*;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

Import javax.swing.*;

Public class Test3 {
Public final static Boolean right_to_left = false;
Static JButton jb = new JButton ("OK"); br> static JTextField tf = new JTextField ("");
Static JTextField TF2 = new JTextField ("");
Static JTextField tf3 = new JTextField ("");
Static JTextArea ta = new JTextArea ("");
public static void Addcomponentstopane (Container contentpane) {
if (right_to_left) {
Contentpane.setcomponentorientation (
Componentorientation.right_to_left);
}
//any number of rows and 2 columns
Contentpane.setlayout (new GridLayout (6,1));

Contentpane.add (New JLabel ("Enter Your Name"));
Contentpane.add (TF);
Contentpane.add (TF2);
Contentpane.add (TF3);
Contentpane.add (JB);
Contentpane.add (TA);
//jb.setmnemonic (keyevent.vk_i);//set ShortCut Keys
Jb.addactionlistener (new ActionListener () {

public void actionperformed (ActionEvent arg0) {
TODO auto-generated Method Stub
string[] test = new STRING[3];

Test[0] = Tf.gettext ();
TEST[1] = Tf2.gettext ();
TEST[2] = Tf3.gettext ();
Ta.settext ("");
for (int i = 0; i < 3; i++) {

if (Test[i].matches ("[a-za-z0-9]{1,6}"))
Ta.settext (Ta.gettext () + "No." +i+ ": OK" + "\ n");
else if (test[i].length () <= 0)
Ta.settext (Ta.gettext () + "No." +i+ ": Input cannot be empty" + "\ n");
else if (Test[i].length () > 6)
Ta.settext (Ta.gettext () + "No." +i+ ": input character length too long" + "\ n");
Else
Ta.settext (Ta.gettext () + "No." +i+ ": Can only enter the English alphabet or the number" + "\ n");

}

}
});
}

private static void Createandshowgui () {
Jframe.setdefaultlookandfeeldecorated (TRUE);

JFrame frame = new JFrame ("GridLayout Source Demo");
Frame.setdefaultcloseoperation (Jframe.exit_on_close);

Set up the content pane and GridLayout
Addcomponentstopane (Frame.getcontentpane ());

Frame.pack ();
Frame.setvisible (TRUE);
}

public static void Main (string[] args) {
Javax.swing.SwingUtilities.invokeLater (New Runnable () {
public void Run () {
Createandshowgui ();
}
});
}
}

The above Java Code compilation environment is a WINDOW8 64-bit system, and the compiler is eclipse.

6. Test results

      

Match the desired result and prove that the test was successful.

7, Summary: Through the actual operation of the software testing, more profound understanding of equivalence class division, and more understanding of the importance of software testing. As the software system grows, so does the software testing that we have with it, so that the resources that consume as little as possible are done with all the parts we want to detect.

8, welcome everyone to my blog criticism.

About software Testing (3): Extended applications based on the previous equivalence class partitioning

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.