"Software Testing" implements editing boxing and tests

Source: Internet
Author: User
Tags addall control characters

    • Problem description
      • Input interval allows only 1 to 6 English characters or numbers to be entered, ending with a submit
      • If the input does not meet the required output error message

    • Equivalence Division Class
Valid equivalence classes Invalid equivalence class
E1: Length: 1 to 6 T1: Length: 0,7
E2: Character: a-z,a-z,0-9 T2: English, characters other than numbers, control characters, punctuation marks

For a editing boxing:

Length: Character
C (correct input) E1:e2 Enter the correct
W1 (a class of error inputs) E1:t2 Input input characters are not completely English and numeric
W2 (Two-class error input) T1:e2 Input length exceeds 6 or input is empty
W3 (three types of error input) Input is empty
    • Design Test Cases
Number Test Cases Expected output
Text1 Text2 Text3 Text1 Text1 Text3
1 (CCC) "ABC2" "ABC2" "ABC2" Enter the correct Enter the correct Enter the correct
2 (W3W3W3) "" "" "" Input is empty Input is empty Input is empty
3 (W2W2W2) "ABC22DD" "ABC22DD" "ABC22DD" Input length more than 6 Input length more than 6 Input length more than 6
4 (W1W1W1) "Abc\\" "Abc\\" "Abc\\" The input characters are not entirely English and numeric The input characters are not entirely English and numeric The input characters are not entirely English and numeric
5 (CCW3) "ABC2" "ABC2" "" Enter the correct Enter the correct Input is empty
6 (CW2C) "ABC2" "ABC22DD" "ABC2" Enter the correct Input length more than 6 Enter the correct
7 (W1CC) "Abc\\" "ABC2" "ABC2" The input characters are not entirely English and numeric Enter the correct Enter the correct
8 (CW3W1) "ABC2" "" "Abc\\" Enter the correct Input is empty The input characters are not entirely English and numeric
9 (W3CW2) "" "ABC2" "ABC22DD" Input is empty Enter the correct Input length more than 6
Ten (W2W1C) "ABC22DD" "Abc\\" "ABC2" Input length more than 6 The input characters are not entirely English and numeric Enter the correct
One (W3W1W2) "" "Abc\\" "ABC22DD" Input is empty The input characters are not entirely English and numeric Input length more than 6
    • Code
ImportJavax.swing.JOptionPane;Importjavafx.application.Application;Importjavafx.event.ActionEvent;ImportJavafx.event.EventHandler;ImportJavafx.geometry.Pos;ImportJavafx.scene.Scene;ImportJavafx.scene.control.Button;ImportJavafx.scene.control.Label;ImportJavafx.scene.control.TextField;ImportJavafx.scene.layout.HBox;ImportJavafx.scene.layout.VBox;ImportJavafx.stage.Stage; Public classEditboxingextendsApplication { Public Static voidMain (string[] args) {//TODO auto-generated Method Stubeditboxing.launch (args); } TextField textfield1=NewTextField (); TextField textfield2=NewTextField (); TextField textfield3=NewTextField (); @Override Public voidStart (Stage primarystage)throwsException {//TODO auto-generated Method StubPrimarystage.settitle ("Editing Boxing"); VBox Root=NewVBox (30 ); Scene Scene=NewScene (Root, 400, 200 );                Primarystage.setscene (Scene); HBox Hbox1=NewHBox (20 ); Textfield1.setprefcolumncount (25 );        Hbox1.setalignment (Pos.center_left); Hbox1.getchildren (). AddAll (NewLabel ("Text1:"), textfield1); HBox Hbox2=NewHBox (20 ); Textfield2.setprefcolumncount (25 );        Hbox2.setalignment (Pos.center_left); Hbox2.getchildren (). AddAll (NewLabel ("Text2:"), textfield2); HBox Hbox3=NewHBox (20 ); Textfield3.setprefcolumncount (25 );        Hbox3.setalignment (Pos.center_left); Hbox3.getchildren (). AddAll (NewLabel ("Text3:"), textfield3); HBox hbox4=NewHBox (20 ); Button btn=NewButton (); Btn.settext ("Submit" ); Btn.setonaction (NewListener ());        Btn.setalignment (Pos.center);        Hbox4.getchildren (). AddAll (BTN);        Hbox4.setalignment (Pos.center);        Root.getchildren (). AddAll (Hbox1, Hbox2, Hbox3, hbox4);    Primarystage.show (); }         Public classListenerImplementsEventhandler<actionevent>{@Override Public voidhandle (ActionEvent arg0) {//TODO auto-generated Method StubString Text1 =Textfield1.gettext (); String Text2=Textfield2.gettext (); String Text3=Textfield3.gettext (); String Inf1= Testing (Text1, "Text1" ); String Inf2= Testing (Text2, "Text2" ); String inf3= Testing (Text3, "Text3" ); String inf= Inf1 + "\ n" + inf2 + "\ n" +inf3; Joptionpane.showmessagedialog (NULL, INF, "Information", Joptionpane.information_message); }                 Publicstring Testing (String arg, String arg1) {string ans= ""; if(arg = =NULL|| Arg.equals ("") ) {ans= arg1 + "Input is empty! "; }            Else if(Arg.length () > 6) {ans= arg1 + "input character length greater than 6"; }            Else{                BooleanPcount =true;  for(inti = 0; I < arg.length (); i++ ) {                    if( ! (Ischar (Arg.charat (i)) | |Isnum (Arg.charat (i)))) {Pcount=false;  Break; }                }                                if(Pcount) {ans= arg1 + "input correct"; }                Else{ans= arg1 + "Input character not fully composed of English characters and Numbers"; }            }                        returnans; }                 Public BooleanIschar (Chararg1) {            if((arg1 >= ' a ' && arg1 <= ' z ') | | (arg1 >= ' A ' && arg1 <= ' Z ' ) ) {                return true; }            Else {                return false; }        }                 Public BooleanIsnum (Chararg1) {            if(arg1 >= ' 0 ' && arg1 <= ' 9 ' ) {                return true; }            Else {                return false; }        }    }}

    • Test

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

"Software Testing" implements editing boxing and tests

Related Article

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.