You are on page 1of 5

2021 IEEE International Conference on Consumer Electronics and Computer Engineering (ICCECE 2021)

Research on test case description language


2021 IEEE International Conference on Consumer Electronics and Computer Engineering (ICCECE) | 978-1-7281-8319-0/20/$31.00 ©2021 IEEE | DOI: 10.1109/ICCECE51280.2021.9342169

Xiang Yu Hongman Wang


Institute of Network Technology; Engineering Research Center Institute of Network Technology; Engineering Research Center
of Information Network, Ministry of Education of Information Network, Ministry of Education
School of Computer Science (National Pilot Software School of Computer Science (National Pilot Software
Engineering School) Engineering School)
Beijing University of Posts and Telecommunications Beijing University of Posts and Telecommunications Beijing,
Beijing, China China
yuxiang@bupt.edu.cn wanghm@bupt.edu.cn

Fangchun Yang
Institute of Network Technology; Engineering Research Center
of Information Network, Ministry of Education
School of Computer Science (National Pilot Software
Engineering School)
Beijing University of Posts and Telecommunications
Beijing, China
fcyang@bupt.edu.cn

Abstract—Software testing is crucial in the development of


software interfaces or web pages. In this paper, a test case II. RELATED WORK
description language (TCDL) is proposed. TCDL can Domain specific language (DSL) is aimed at a specific
conveniently describe the process of web UI testing with a domain. It is closer to natural language logic in use to
grammar that is close to natural language and conforms to
provide a simple and readable business layer abstraction for
manual operation logic. In this paper, the manual UI testing
the underlying test code. Wang Minglan [6] and others have
process is abstracted by TCDL, and the syntax specification of
conducted research on test description languages in various
TCDL is designed, and the parsing of TCDL is realized with
the help of ANTLR tool. Using TCDL, testers can quickly fields, organized and analyzed them according to different
write test scripts with manual test logic. TCDL reduces the platforms and application fields. Long Xiaoqi [7] and others
learning cost of users and improves the testing efficiency. designed a test script language for the train safety software
test system, which decomposes test cases into test units and
Keywords-software testing; domain specific language; belongs to embedded software testing. Su Mang [9] and
TCDL; ANTLR others proposed a proxy re-encryption oriented PLPRE
language for cryptographic re-encryption algorithms, which
I. In t r o d u c t io n
described the code re-encryption algorithm in a natural
language and solved the problem that computer
In the software development process, automated testing programmers are unfamiliar with the mathematical theory of
is crucial [1]. Web UI is the medium for direct interaction cryptographic algorithms. The researches above simplify the
between software and users [2]. Iterative testing to ensure its scripts in the testing process of various fields, and provides
normal operation is an important part of improving user design ideas for the TCDL proposed in this paper. The
experience. The main method of UI function testing is languages above are only for specific fields such as
running the Groovy script on the Java server which calls the embedded or encryption algorithms. At present, there is no
Selenium engine. When testers write programs, they large-scale application of test description languages that
generally need to pay attention to language grammar, approximate natural language logic in the field of web UI
imported dependencies, etc., which require testers to have a testing. Some existing general webpage test description
high level of programming. However, in most test processes, languages mostly use XML [11], mainly describe input and
testers generally expect to pay attention to the operation output data, while the main description goal of the webpage
process, test data, etc. [3], and expect the test language to be test description language is the operation behavior of the
simple, clear, easy to understand and conforming to natural webpage. Writing groovy scripts directly requires familiarity
language logic to reduce learning costs and to improve test with programming language rules, and there are problems
efficiency and throughput [4][5]. In this paper, a test case such as complex representation of data, which is difficult for
description language (TCDL) is proposed to simplify the test the majority of testers. In this paper, aiming at the problems
script and to improve test efficiency and test throughput, to of difficulty in writing test scripts and high learning cost, the
speed up the iterative test process and software development operation of web page test is abstractly expressed, and
speed. TCDL language is proposed. TCDL uses a format that
conforms to the manual test process to describe the
operation steps of the test process and uses the ANTLR tool

978-1 -7281 -8319-0/21/$31.00 ©2021 IEEE


27

Authorized licensed use limited to: Western Sydney University. Downloaded on June 14,2021 at 15:09:42 UTC from IEEE Xplore. Restrictions apply.
to parse the TCDL statement to generate the corresponding B. Program structures
groovy script. TCDL can not only effectively describe the In the language definition, the Backus-Naur form (BNF)
web UI test process, but also can be translated as is generally used for expression. The following statements
programming language test code, helps solve the problem of are BNF [13][14] expressions of TCDL:_________________
simplifying the web test language and promote the BNF________________________________________________
efficiency of UI function testing. BEGIN:
<program>::=<import_list><function_block>
III. TEST CASE DEDCRIPTION LANGUAGE <import_list>:: - ’import “<package>”;”
<package>::=*(<var>”.”)<var>”;”
A. Design goals <function_block>: :=<statement>
<function_name>: :=<ID>
In the design of description language, readability, <statement>:;=<expressions>|<functions>
writability and implementation cost can be used as language <functions>::=*(<function>|<staticfunction>)
evaluation criteria. <function>::=<ID>”(“<varList>”)”
TCDL is in the business layer of the test process and <staticfunction>::=<ID>”.“<ID>”(“<varList>”)”
should shield the details of the technical layer (executable <expressions>::=*(<expression>)<expression>
scripts). The TCDL script should be translated as a <expression>::=<ui>”.”<elementtype>”.”<elementfunction>”;”
(“#”<varList>)?
programming language script and executed by the computer.
<ui>: :=<ID>”(“<varList>”)”
Design goals of TCDL are as follows:
<elementtype>::=<ID>”(“<varList>”)”
1) The operation and meaning of the test case can be <elementfunction>::=<ID>”(“<varList>”)”
expressed completely and accurately with logic close to <comment>: :=<varList>
manual testing. <varList>: :=*(<var>”,”)<var>
<var>::=<ID> |<BOOLEAN>| <DIGIT> |<function>
2) A script can be translated as an executable <ID>::=<ALPHA>|”_”*(<ALPHA>|<DIGIT>|”_”)
language script. <BOOLEAN>::=”true”|”false”|”TRUE”|”FALSE”
<ALPHA>: :=%X41-5A|%61-7A
3) The translation process is idempotent. Translating <DIGIT>::=%X30-39s
the same TCDL case multiple times can get the same result. END________________________________________________
4) Meet the evaluation criteria of readability and The following statement is a pseudo code of a TCDL
writability. expression:
In the operation process of the webpage test, the user’s “U r “(”<variable>“)”“.”“ElementName”“(”<elementVar
test operation behavior can be simply summarized as: open a >u)”u.”uFunction”u(”<functionVar>u)”“;””\n”
specific webpage and operate on a certain web element. It 1) Grammar rules
generally follows the processing flow of "webpage-element-
operation”, and similarly, the design of TCDL sentence An expression is divided into three information modules:
should also follow the natural operation flow to facilitate window, element, and method, which are separated by ”.”.
users’ understanding. Groovy script needs location Semicolon ”;” is used to separate TCDL statements. The
parameters of web pages and elements for positioning, and ”ElementName” and ’’Function” represent the behavior
operation parameters are needed for element operation. The description of user logic, and the parameter ”elementVar”
TCDL statement needs to integrate the parameters required and the parameter ”functionVar” are the data description
by the script logic. The abstraction of TCDL’s operations on from the script logic.
webpage elements should highlight user logic and use script
2) Operator
logic as parameters, as shown in the following figure:
o The web UI test process does not involve mathematical
O User logic (Operation description) operations, so TCDL does not provide mathematical
operator operations. Only the separator and comment
symbols are kept.
3) Variable name
The variables in TCDL mainly represent the names and
positioning parameters of webpage elements. TCDL
statements support variable names defined by letters,
numbers, and underscores, and statement parameters support
Script logic (Data description)
variables, decimal integer numbers, and Boolean values.
Figure 1. User logic and script logic 4) Function operation
The TCDL expression sentence can describe the test
steps conforming to ”Webpage-Element-Operation”.
However, operations such as opening webpages and other

28

Authorized licensed use limited to: Western Sydney University. Downloaded on June 14,2021 at 15:09:42 UTC from IEEE Xplore. Restrictions apply.
non-webpage element operations do not comply with the
testing process. In order to complete the coverage of other
web page operations, the TCDL function statement is
introduced. The testers write the TCDL function for the
specific operation that needs to be described. The syntax
expression of function statement is:
“FunctionName”“(”<functionVar>“)”“;””\n”

C. Data definition
The UI test script statement needs positioning parameters
of the web page element during execution. When the
positioning element is written in the TCDL sentence, the
element needs to be re-configured when the step changes. Figure 3. Analyzing o f TCDL
The writing complexity of the sentence is increased. In order
to achieve the readability of TCDL and the reuse of element According to the grammatical structure mentioned
positioning parameters, positioning parameters are stored in above, the corresponding part of the ANTLR rule is:
the database in the form of key-value pairs. The key is the a n t l r
unique name configured by users for the web element, and BEGIN:
the value is the positioning parameter of the element. When statement
the webpage changes, modify parameters in the database, :(obj ectOperationStatement
which improves the data readability and writability of the |funcOperationStatement)*;
script positioning operation. As the figure below shown: obj ectOperationStatement
:ui'.'controllType'.'controllFunction';'argcomment?;
UI(“page").webedit(“editVar").set(“content"); argcomment:'#'variableExpressionList;
funcOperationStatement:ID'('varExpList?')'';';
ui:ID'('varExpList?')';
K-V Database “editVar”-7/*[@id="kw"]" controllType :ID'(' varExpList?')';
controllFunction:ID'('varExpList?')';
varExpList: varExp(','varExp)*;
varExp:ID|BOOLEAN|NUMBERjson|varExp(('and'|'or')
//*[@id="kw"] varExp)+|'('varExp')';
ID:('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
Figure 2. Requirement o f K-V value END_______________________________________________
Take a TCDL statement as an example:
IV. An a l y z in g o f TCDL UI("var").webedit("editVar").set("content");
The syntax analysis tree of the statement is shown in the
A. Analyzing o f TCDL statements
following figure:
Compared with other programming languages, TCDL is
only oriented to automated testing and describes test UI(“var").webedit(“editVar").set(“content");
operations. It is an incomplete abstract language and cannot
be directly executed by computer, needs to be translated to
target code script to run. To complete the translation of
TCDL sentences, the grammatical elements contained in the
TCDL sentences are needed to be parsed out and to be
ID: UI ( varExp ) ID: webedit ( varExp ) ID: set ( varExp )
replaced for the real executable script.
ANTLR [15] is a powerful syntactic analyzer generation
tool, which is used to read or translate structured texts. It has “var” “editVar” “content”
been widely used in syntax analysis of various language.
Figure 4. TCDL syntax analysis tree
When TCDL script is being translated, ANTLR is used to
parse TCDL sentences and to build a grammatical analysis
The program accesses the leaf nodes of the syntax
tree. The leaf nodes of the grammatical analysis tree are
analysis tree to obtain the syntax elements of the TCDL
composed of test case syntax elements. Then visit the leaf
statement.
node, replace the TCDL script elements to get the executable
script. Statements parsing needs to go through the stages of
B. Generate o f the target code
lexical analysis, syntax analysis, semantic analysis, and
access to the syntax analysis tree, as shown in the following After obtaining the constituent elements of the TCDL
figure: statement, the statement needs to be converted into an
executable statement. The target code comes from the test

29

Authorized licensed use limited to: Western Sydney University. Downloaded on June 14,2021 at 15:09:42 UTC from IEEE Xplore. Restrictions apply.
execution class configured by the test developer in the expression of the generated syntax analysis tree is as
execution server like: follows:
WebEdit_SeleniumImpl.getInstanceO.LocateTestObject( (statement (objectOperationStatement (ui UI (
“UrVar”,“edifVar”).Set("content"); (varExpList (varExp "var")) )) . (controllType webedit (
(varExpList (varExp "editVar")) )) . (controllFunction set (
The target code sentence is related to the element type,
(varExpList (varExp "content")) )) ;))
and the main body of the sentence can be recorded in the
database. The target language template code can be in the This parse tree complies with the design rules of TCDL,
following format: and the generated sentence fragments are:
WebEdit_SeleniumImpl.getInstance().LocateTestObject( W ebEdit_SeleniumImpl. getInstance().LocateT estObject(
${{UI}},${{element}}).Set(${{input}}); "var", "//*[@id="kw"]").Set("content");
${{UI}}, ${{element}}, ${{input}} are the flags of the The execution result of generated target code is that
three statement parameters. In the process of translation, the "content" is entered in the search box on the webpage, which
parameters are accessed in order, from the left to the right to is consistent with the expected effect, which can prove that
find the token ${{}} to replace the parameters in the the TCDL language can be parsed into the correct syntax
statement. Searching in order can ensure that the same result analysis tree and complete the test task.
can be obtained in translation, that is, idempotence is
guaranteed. The following figure shows the process of D. TCDL characteristics
generating the target code: 1) Technical requirements
webedit target template code:
TCDL is mainly for web page function testing. TCDL
"WebEdit_SeleniumImpl.getInstance().LocateTestObject(${ {UI}}, ${ {element}}).Set(S{ {content}});'
sentence structure is close to test operation logic, easy to
' .— 1 .
understand, and data is configured in the form of parameters.
“editVar” - " / / * [@ id= "kw "]" content TCDL sentences are easier to use and can reduce the ratio of
professional programmers to ordinary testers.
RE PLA CE :
2) Script comparison
W eb E d it....g etIn stan ce().L o cateT estO bject(‘fUIVar”,“//*[@ id= Mk w "]” ).S et("content");

Figure 5. Generate o f the target code


Take a web page testing process as an example:______
Natural language description of the test process_____________
In summary, by analyzing TCDL syntax elements, BEGIN:
accessing the syntax analysis tree, and replacing variables, Open the home page of the search engine, and the website
address is "searchURL";
the TCDL statement representing one step of the test
Memorize the opened webpage as "var";
operation can be translated into executable code, thereby
Find search box and enter the "content" in it;
generating a complete test case fragment as the part of the Find the confirm search button and click the button.
test class. Then code is spliced together with import END_______________________________________________
dependency statements to form a complete test file. Groovy script for performing test operation is:_________
The difference between TCDL language parsing and groovy_______________________________________________
others in the target code generation is that it does not obtain BEGIN:
the generated target code by visiting the parse tree from the import
leaf node to the root node. Instead, only the leaf nodes of the control.impl.web.selenium.browser.Browser_SeleniumImpl;
syntax analysis tree are accessed to obtain syntax elements import control.impl.web.selenium.edit.WebEdit_SeleniumImpl;
and used to replace in reserved target codes. The advantage import org.openqa. selenium. WebDriver;
is that it is not necessary to modify ANTLR when the test
def testFunc(WebDriver driver) {
system changed, testers just modify the template target code,
so that TCDL can quickly migrate to different test systems. Browser_SeleniumImpl. getInstance(). getURL("searchURL
");
C. Verification WebEdit_SeleniumImpl.getInstance().LocateTestObject("va
Verifying the correctness of the TCDL statement r", "//*[@id="kw"]").Set("content");
translation is equivalent to verify whether the code execution WebButton_SeleniumImpl.get[nstance().LocateTestObject(
steps and effects are consistent with the effect expected by "var", "//*[@id="su"]").Click();
the user when configuring the statement. Experiment is done
to verify whether the set ANTLR rules can construct a }
correct parse tree using a TCDL statement: END_________________________________________________
A test case using TCDL is:____________________________
UI(“var”).webedit(“editVar”).Set(“content”); TCDL______________________________________________
BEGIN:
The "editVar" is the key in the database of location xpath
getURL(“searchURL”); #function
of the search box. Execute the ANTLR interpreter, the string UI(“var”).webedit(“editBox”).Set(“content”);_______________

30

Authorized licensed use limited to: Western Sydney University. Downloaded on June 14,2021 at 15:09:42 UTC from IEEE Xplore. Restrictions apply.
UI(“var”).webbutton(“clkButton”).ClickQ; Re f e r en c es
END [1] Hui Lu. Test Description Language of Automatic Test System.
Beijing: China Machine Press.2011.5.
[2] Zhenxing Lin. Research and Design o f Logistics Software Test Case
The test data that needs to be configured is the key-value
Description System. Beijing University of Posts and
pair: "editBox-//*[@id-’kw"]", "clkButton-//*[@id="su"]". Telecommunications, 2019.
TCDL scripts have lower requirements for testers' [3] Fenghua Li, Junzhi Yan , Rongna Xie, Jianfeng Ma, Haiwen Ou.
programming level. Script writing and data configuration are Research on the Programming Language for the Block Cipher
more concise. It’s more readable and closer to natural Algorithm. Acta Electronica Sinica, 2009,37(12), pp. 2705-2710.
language logic are more suitable for the needs o f web page [4] Yunlong Zhi. Design and Implementation of Open Clinical Quality
function testing. Language. Zhejiang University,2018.
[5] Jing Jiang. Design and Implementation of Domain-specific Language
3) Learning costs for Computer Vision. University o f Science and Technology of
China,2020.
According to experience statistics, the format of TCDL
[6] Minglan Wang, Dongsheng Ye. Research o f test case description
sentences is simple, and it takes about two weeks to master language. Computer Engineering and Design,2006(22). pp. 4281­
the writing method. However, programming language 4284.
scripts requires one to two months of learning time. The [7] Xiaoqi Long, Jiahuan Zhang, Lin Tang, Zehua Chen, Peng Jiang. A
following table is a comparison o f the experience o f using Scripting Language for Embedded Software Automatic Test. Control
programming language to write scripts and in TCDL: and Information Technology,2019(03). pp. 48-51+55.
[8] Chen Meng. The Design and Implementation o f the Test Flow
Description Language. Acta Armamentarii,2007(01). pp.91-93.
TABLE I. Ad v a n t a g e o f TCDL
[9] Mang Su, Yan Yu, Bin Wu, Anmin Fu. Research on the
— — — ....... TCDL Others programming language for proxy re-encryption. Journal on
Communications, 2018,39(06). pp. 89-97.
Cross-platform Y N
[10] Jihua Liu, Fengfeng Bai, Yan Qiang. RASL:Embedded automatic
Close to natural Y N test language. Computer Engineering and Design, 2019,40(06). pp.
language 1642-1647.
Time to learn 15 days About 45 days [11] Christophe Strobbe. Test Case Description Language (TCDL): Test
Human resources 10 test 2 test developers Case Metadata for Conformance Evaluation[J]. Lecture Notes in
developers 8 testers Computer Science,2006,4061:164-171
Composition ratio — ............. 1: 4 [12] Dan Yu, Shilong Ma. Design and Implementation of Spacecraft
Automatic Test Language. Chinese Journal o f Aeronautics,
V. Co n c l u s io n 2011,24(03). pp. 287-298.
[13] Peter Linz. An Introduction to Formal Languages and Automata,
A test case description language TCDL is designed in Third Edition. Jones and Bartlett Computer Science.
this paper. TCDL realizes the standardization of test case [14] Alfred,V.A., Monika S. L., Ravi Sethi, Jeffrey D.U. Compilers:
execution steps, while ensuring the idempotence and Principles, Techniques and Tools, Second Edition. Pearson Edution.
correctness o f the translation process. The simplified [15] Terence Parr. The Definitive ANTLR 4 Reference. The Pragmatic
language expression makes the readability of TCDL Programmers.
sentences greatly improved compared with general [16] Xiaobin Ning, Wenmin Yi, Weijian Luo. A Web Service Testing
programming languages, and it is easy to modify, which Method Based on TTCN-3. Computer Applications and Software,
reduces the requirement o f user programming level and 2012,29(06). pp. 216-218.
expands the use range of the TCDL. The use of TCDL has
greatly improved test efficiency and throughput.

31

Authorized licensed use limited to: Western Sydney University. Downloaded on June 14,2021 at 15:09:42 UTC from IEEE Xplore. Restrictions apply.

You might also like