We often need to enter multiple information at the same time when filling in the information, and must meet the input requirement.
In the original input box to increase the input requirements, the input is increased to three, there is more than one illegal input is not the result of judgment, only three inputs are correct when the input is determined to be successful.
Equivalence class Partitioning
| Number |
Valid equivalence classes |
Number |
Invalid equivalence class |
| 1 |
Length <6 |
5 |
Length = 0 or >7 |
| 2 |
Digital |
6 |
control characters, punctuation |
| 3 |
lowercase English letters |
|
|
| 4 |
Uppercase English letters |
|
|
| Use Case number |
Line |
Two lines |
Propelled |
Results |
| (1) |
|
Asd |
Wer3 |
Illegal |
| (2) |
Tcy2 |
Flower |
Lion20 |
Pass |
| (3) |
answ! |
21345 |
3.1415 |
Illegal |
| (4) |
112233 |
44556 |
7895999 |
Illegal |
| (5) |
Apple |
Banana |
Peach |
Pass |
| (6) |
|
|
|
Illegal |
| (7) |
[Email protected] |
Br_er |
Wer_12 |
Illegal |
| (8) |
Asdfghjk |
123 |
Asnf |
Illegal |
| (9) |
12345678 |
Fly |
Carer |
Illegal |
| (10) |
Emanon |
Neo |
Jhon |
Pass |
Test results
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
Importjavafx.application.Application;Importjavafx.event.ActionEvent;ImportJavafx.event.EventHandler;ImportJavafx.scene.Scene;ImportJavafx.scene.control.Button;ImportJavafx.scene.control.TextField;ImportJavafx.scene.layout.AnchorPane;ImportJavafx.scene.text.Text;ImportJavafx.stage.Stage; Public classTestingextendsApplication { Public Static voidMain (string[] args) {testing.launch (args); } Public voidStart (Stage primarystage) {primarystage.settitle ("Input Testing" ); Anchorpane Root=NewAnchorpane (); Text text=NewText ("Please enter user name"); FinalText textans1 =NewText (""); FinalText Textans2 =NewText (""); FinalText TEXTANS3 =NewText (""); FinalTextField Intext1 =NewTextField (""); Intext1.setmaxsize (140, 20); Anchorpane.settopanchor (text,80.0); Anchorpane.setleftanchor (text,110.0); Anchorpane.settopanchor (textans1,240.0); Anchorpane.setleftanchor (textans1,70.0); Anchorpane.settopanchor (Textans2,260.0); Anchorpane.setleftanchor (Textans2,70.0); Anchorpane.settopanchor (TEXTANS3,280.0); Anchorpane.setleftanchor (TEXTANS3,70.0); Anchorpane.settopanchor (Intext1,100.0); Anchorpane.setleftanchor (Intext1,70.0); FinalTextField intext2 =NewTextField (""); FinalTextField INTEXT3 =NewTextField (""); Intext2.setmaxsize (140, 20); Intext3.setmaxsize (140, 20); Anchorpane.settopanchor (INTEXT2,140.0); Anchorpane.setleftanchor (INTEXT2,70.0); Anchorpane.settopanchor (INTEXT3,180.0); Anchorpane.setleftanchor (INTEXT3,70.0); Root.getchildren (). AddAll (TEXT,INTEXT1,INTEXT2,INTEXT3); Root.getchildren (). AddAll (TEXTANS1,TEXTANS2,TEXTANS3); Button btn=NewButton ("Submit"); Root.getchildren (). AddAll (BTN); Anchorpane.settopanchor (BTN,210.0); Anchorpane.setleftanchor (BTN,120.0); Btn.setonaction (NewEventhandler<actionevent>() { Public voidhandle (ActionEvent arg0) {Textans1.settext (""); Textans2.settext (""); Textans3.settext (""); if(Check (Intext1.gettext (). toString ())! = "entered correctly") Textans1.settext ("Number one failed:" +Check (Intext1.gettext (). toString ())); if(Check (Intext2.gettext (). toString ())! = "entered correctly") Textans2.settext ("Number second failed:" +Check (Intext2.gettext (). toString ())); if(Check (Intext3.gettext (). toString ())! = "entered correctly") Textans3.settext ("Number third failed:" +Check (Intext3.gettext (). toString ())); if(Check (Intext1.gettext (). toString ()) = = "Input correct" &&Check (Intext2.gettext (). toString ())= = "input correct" &&Check (Intext3.gettext (). toString ())= = "input correct") {Textans1.settext (By); Textans2.settext (""); Textans3.settext (""); } } }); Primarystage.setscene (NewScene (root,300,300)); Primarystage.show (); } Publicstring Check (String str) {CharArray[] =New Char[Str.length ()]; Array=Str.tochararray (); if(Str.length () < 1) return"Input cannot be empty"; if(Str.length () > 6) return"Input exceeds the length limit, please modify"; if(Str.length ()! = 0){ for(inti = 0; I < str.length (); i++){ if(! ((array[i]>= ' a ' && array[i]<= ' z ') | | (array[i]>= ' A ' && array[i]<= ' Z ') | | (array[i]>= ' 0 ' && array[i]<= ' 9 '))) return"Contains illegal characters, please modify"; } } return"Input correct"; } }
Equivalence class partitioning method for black-box testing Software testing (2)