java批量生成用例脚本-保留字关键词的用例脚本生成

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java批量生成用例脚本-保留字关键词的用例脚本生成相关的知识,希望对你有一定的参考价值。

20171012新补丁包程序,程序整理了全部的关键字和保留字,支持 字段a = "字段b" 与 字段a = 字段b,并做了代码重构。对补丁包进行关键字专项测试,验证关键字保留字作为库、表、视图、字段、词典等情况

package com.io.test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class ConstTest01 {

    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
        String path01 = "C:\\tmp\\const.txt";
        String path02 = "C:\\tmp\\ksql.txt";
        
        FileInputStream fis = new FileInputStream(path01);
        InputStreamReader isr = new InputStreamReader(fis);
        BufferedReader br = new BufferedReader(isr);
        
        FileOutputStream fos = new FileOutputStream(path02);
        OutputStreamWriter osr = new OutputStreamWriter(fos);
        BufferedWriter bw = new BufferedWriter(osr);
        
        String temp;
        String temp01;
        while((temp=br.readLine())!=null)
        {
            if(temp.contains("\""))
            {
                String[] arr = temp.split("\"");
                temp01 = arr[1];
                bw.write("--<DROP>");
                bw.newLine();
                temp = "drop table "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<CREATE>");
                bw.newLine();
                temp = "CREATE TABLE "+temp01+"\nPATH \‘C:\\tmp\\table\\"+temp01+"\‘\nAT temp \n("+temp01+" INTEGER(8) NORMAL,test INTEGER(8) NORMAL)\ngo";
//                System.out.println(temp);
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<INSERT>");
                bw.newLine();
                temp = "INSERT INTO "+temp01+"("+temp01+",test)\nVALUES(0,12345678)\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<SELECT recordset=1-*>");
                bw.newLine();
                temp = "SELECT * FROM "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<UPDATE>");
                bw.newLine();
                temp = "update "+temp01+" set "+temp01+"= test\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<SELECT recordset=1-*>");
                bw.newLine();
                temp = "SELECT * FROM "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<UPDATE>");
                bw.newLine();
                temp = "update "+temp01+" set "+temp01+"= \"test\"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<SELECT recordset=1-*>");
                bw.newLine();
                temp = "SELECT * FROM "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<DROP>");
                bw.newLine();
                temp = "drop table "+temp01+"\ngo\n";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<CREATE>");
                bw.newLine();
                temp = "CREATE VIEW "+temp01+" AS SELECT * FROM SYS_LOG_1\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<SELECT recordset=1-*>");
                bw.newLine();
                temp = "SELECT * FROM "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<DROP>");
                bw.newLine();
                temp = "DROP  VIEW "+temp01+"\ngo\n";
                bw.write(temp);
                bw.newLine();
                    
                bw.write("--<CREATE>");
                bw.newLine();
                temp = "CREATE DATABASE "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<DROP>");
                bw.newLine();
                temp = "DROP DATABASE "+temp01+"\ngo\n";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<DROP>");
                bw.newLine();
                temp = "drop SORTDICT "+temp01+"\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<CREATE>");
                bw.newLine();
                temp = "CREATE SORTDICT "+temp01+"\nPATH \‘C:\\\\tmp\\\\table\\\\‘ \nALIASNAME \""+temp01+"\" \nORDER BY SPELL\nMAXWORDLEN 30\nSORTVALUENUM 1\ngo";
                bw.write(temp);
                bw.newLine();
                
                bw.write("--<DROP>");
                bw.newLine();
                temp = "drop SORTDICT "+temp01+"\ngo\n";
                bw.write(temp);
                bw.newLine();
            }else if(temp.contains("///"))
            {
                temp=temp.trim().replace("///", "------");
                System.out.println(temp);
                bw.write(temp);
                bw.newLine();
            }
//            bw.write(temp);
//            bw.newLine();
        }
        
        bw.flush();
        bw.close();
    }

}

以上是关于java批量生成用例脚本-保留字关键词的用例脚本生成的主要内容,如果未能解决你的问题,请参考以下文章

Python单元测试框架unittest之批量用例管理(discover)

Python 中使用 ddt 来进行数据驱动,批量执行用例,修改ddt代码

robotframework怎样设置脚本运行的次数

批量生成python自动化测试脚本

Python中“通过”的用例是啥? [复制]

Jmeter 为两个不同的用例在图中定义 X 轴值