zoukankan      html  css  js  c++  java
  • 黑盒测试等价类划分方法 续

    接上一篇,有三个输入框,都要求输入1-6个英文字符或数字。

    测试用例:

    09aaaaa 不合法
    0+09 不合法
    009a 合法输入

    下面是测试结果:

      

    源代码如下:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                label4.Text = "请先输入";
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                String[] str = new String[3];
    
                str[0] = textBox1.Text;
                str[1] = textBox2.Text;
                str[2] = textBox3.Text;
    
                Boolean res1 = System.Text.RegularExpressions.Regex.IsMatch(str[0], @"^[a-zA-Zd]{1,6}$");
                Boolean res2 = System.Text.RegularExpressions.Regex.IsMatch(str[1], @"^[a-zA-Zd]{1,6}$");
                Boolean res3 = System.Text.RegularExpressions.Regex.IsMatch(str[2], @"^[a-zA-Zd]{1,6}$");
    
                if (res1)
                    label4.Text = "用户名输入正确";
                else
                    label4.Text = "用户名输入不正确";
                if (res2)
                    label5.Text = "密码输入正确";
                else
                    label5.Text = "密码输入不正确";
                if (res3)
                    label6.Text = "验证码输入正确";
                else
                    label6.Text = "验证码输入不正确";
            }
        }
    }
    

     

  • 相关阅读:
    selenium自动化测试资源整理
    python获取目录下文件夹名称
    Appium-测试失败后屏幕截图的
    appium 多个设备同时执行
    七 Appium常用方法介绍
    六 APPIUM Android 定位方式
    Python运维开发基础08-文件基础
    Python运维开发基础09-函数基础
    Python运维开发基础06-语法基础
    Python运维开发基础07-文件基础
  • 原文地址:https://www.cnblogs.com/dengye/p/4376063.html
Copyright © 2011-2022 走看看