Skip to content

MO-Tester Specification

Case specifications

Specification Description
File name
1. Use .sql or .test as the suffix.

2. The file name has a practical meaning. For example, if you need to write a index case, you can name the index case index.sql or index_xxxx.sql.
Case
1. In the specific example content in the case, all empty lines are automatically ignored during testing. You can add blank lines to make the SQLs more readable.

2. Each SQL statement contains only one line. If multiple lines are required, each line must be preceded by no space. Otherwise, the SQL in the case file and the result file cannot match each other completely.

3. Add a comment indicating the purpose of the test case you are currently writing.

4. Add a Tag to the case that is in need.

Tag specifications in the cases

Annotation Start with End with Description
-- @bvt:issue -- @bvt:issue#{issueNO.}] -- @bvt:issue the SQL marked with this flag will not been executed
-- @sessio -- @session:id=X{ -- @session} all the SQLs enclosed by this tag will execute in a new session with id=X
-- @separator / / The specified SQL statement in its result and generated the result file using the columns of the separator. There are two values.
-- @separator:table / / The column separator in the result is a TAB character. \t
-- @separator:space / / The column separator in the result is four Spaces
-- @sortkey -- @sortkey:1,2,3 / The results of the SQL statement are ordered, with the first, second, and third columns (starting from 0) sorted. Under normal circumstances, the tested system returns the result of the order is not fixed, so tools in comparison, the actual results, and expected results are sorted, but for some SQL, the expected results should be ordered, such as order by statement, you need to add such SQL on the tag, The tool does not reorder these columns in sortkey when comparing them.

Result specifications

Specification Description
Normal cases generate test results
1. If a case file is created, ensure that all SQL is debuggable and use the Mo-Tester tool to generate results automatically.

2. If some SQLs are added to the existing case, ensure that all SQLs has passed debugging, and use the Mo-Tester tool to generate results automatically.
Cases with tags generate test results
1. If a case contains SQL with the --bvt:issue tag, use the MO-Tester tool to generate results automatically. SQL with the --bvt:issue tag in the generated result file results as' unknown result because it is related to issue#XXX" '.

2. If the results have been automatically generated by the MO-Tester tool. When the results are automatically generated by the MO-Tester tool again, the SQL with the tag --bvt:issue will retain the original value in the generated result file, no more updates.
Write results manually
1. If the result is writed manually, do not have empty lines. Otherwise, a parsing error occurs.

2. If there are tabs or more than 4 consecutive spaces in the expected execution result of a certain SQL, the corresponding SQL statement in the test case file must be added with Tag -- @separator:, otherwise the parsing will fail. For example, if the SQL in the case file contains 4 consecutive spaces, you need to specify the Tag label -- @separator:table; if it contains tab characters, specify the Tag label -- @separator:space.

Set tags in case scripts

Sometimes, to achieve some specific purposes, such as pausing or creating a new connection, you can add some special tags to the script file. The mo tester provides the following tags for use:

Tags Description
-- @skip:issue#{IssueNo.} If set, the whole script file will be skipped, and not be executed any more for issue{IssueNo.}
-- @bvt:issue#{IssueNo.}
-- @bvt:issue
The sql statements between those two tags will be not executed for issue{IssueNo.}
-- @sleep:{time} The mo-tester will wait for {time} s
-- @session:id=2&user=root&password=111
-- @session
The mo-tester will create a new connetion to execute sql statements between those two tags.
Default value of id is 1, max is 10.
Defualt value of user and password is configured in mo.yml.
-- @sortkey: If the result is sorted, need set this tag for the sql statement. e.g.
-- @sortkey:0,1: means sort keys are first column and second colum.