mtr Test Case Content-Formatting Guidelines

When you write a test case, please keep in mind the following general guidelines.
当您编写一个测试用例时,请记住以下一般准则。

There are C/C++ coding guidelines in the MySQL Internals manual; please apply them when it makes sense to do so: Coding Guidelines.
MySQL内部手册中有C/ c++编码指南;请在有意义的时候应用它们:编码指南。

Other guidelines may be found in this page, which discusses general principles of test-case writing: MySQL Internals: How to Create Good Test Cases
其他的指导方针可以在这个页面中找到,它讨论了编写测试用例的一般原则:MySQL内部:如何创建好的测试用例

The following guidelines are particularly applicable to writing test cases:
下面的指导原则特别适用于编写测试用例:

  • To write a test case file, use any text editor that uses linefeed (newline) as the end-of-line character.
    要编写一个测试用例文件,可以使用任何使用换行符作为行尾字符的文本编辑器。

  • Avoid lines longer than 80 characters unless there is no other choice.
    除非没有其他选择,否则避免行长度超过80个字符。

  • A comment in a test case is started with the "#" character.
    测试用例中的注释以“#”字符开始。

    mysqltest Input Conventions discusses the details of input syntax for mysqltest test cases.
    mysqltest输入约定讨论了mysqltest测试用例的输入语法细节。

  • Use spaces, not tabs.
    使用空格,而不是制表符。

  • Write SQL statements using the same style as our manual:
    使用与手册相同的风格编写SQL语句:

    • Use uppercase for SQL keywords.
      SQL关键字使用大写。

    • Use lowercase for identifiers (names of objects such as databases, tables, columns, and so forth).
      使用小写字母表示标识符(对象的名称,如数据库、表、列等)。

    Ignore this guideline if your intent is to test lettercase processing for SQL statements, of course.
    当然,如果您的目的是测试SQL语句的字母处理,请忽略这条准则。

    Use lowercase for mysqltest commands (echo, sleep, let, and so forth).
    mysqltest命令使用小写(echo, sleep, let等等)。

    You may notice that many existing test cases currently do not follow the lettercase guideline and contain SQL statements written entirely in lowercase. Nevertheless, please use the guideline for new tests. Lettercase for older tests can be left as is, unless perhaps you need to revise them significantly.
    您可能会注意到,许多现有的测试用例目前没有遵循字母准则,而是包含完全用小写书写的SQL语句。尽管如此,对于新的测试请使用指南。旧考试的字母可以保持原样,除非你需要大幅修改。

  • Break a long SQL statement into multiple lines to make it more readable. This means that you will need to write it using a ";" delimiter at the end of the statement rather than using "--" at the beginning because the latter style works only for single-line statements.
    将一个长SQL语句分成多行,以使其更具可读性。这意味着您需要在语句末尾使用“;”分隔符来编写它,而不是在开头使用“——”,因为后一种风格只适用于单行语句。

  • Include comments. They save the time of others. In particular:
    包括注释。他们节省了别人的时间。特别是:

    • Please include a header in test files that indicates the purpose of the test and references the corresponding worklog task, if any.
      请在测试文件中包含一个头,表明测试的目的并引用相应的工作日志任务(如果有的话)。

    • Comments for a test that is related to a bug report should include the bug number and title.
      与bug报告相关的测试注释应该包括bug编号和标题。

    Worklog and bug numbers are useful because they enable people who are interested in additional background related to the test case to know which worklog entries or bug reports to read.
    工作日志和bug编号是有用的,因为它们使那些对与测试用例相关的附加背景感兴趣的人知道应该阅读哪些工作日志条目或bug报告。

Example SQL statement, formatted onto multiple lines for readability:
示例SQL语句,为了可读性格式化为多行:

SELECT f1 AS "my_column", f10 ....
FROM mysqltest1.t5
WHERE (f2 BETWEEN 17 AND 25 OR f2 = 61)
  AND f3 IN (SELECT ....
             FROM mysqltest1.t4
             WHERE .....)
ORDER BY ... ;

Example test file header:
示例测试文件头:

########### suite/funcs_1/t/a_processlist_val_no_prot.test #############
#                                                                      #
# Testing of values within INFORMATION_SCHEMA.PROCESSLIST              #
#                                                                      #
# The prepared statement variant of this test is                       #
# suite/funcs_1/t/b_processlist_val_ps.test.                           #
#                                                                      #
# There is important documentation within                              #
#       suite/funcs_1/datadict/processlist_val.inc                     #
#                                                                      #
# Note(mleich):                                                        #
#    The name "a_process..." with the unusual prefix "a_" is           #
#    caused by the fact that this test should run as second test, that #
#    means direct after server startup and a_processlist_priv_no_prot. #
#    Otherwise the connection IDs within the processlist would differ. #
#                                                                      #
# Creation:                                                            #
# 2007-08-09 mleich Implement this test as part of                     #
#                   WL#3982 Test information_schema.processlist        #
#                                                                      #
########################################################################

Example test reference to bug report:
bug报告的示例测试引用:

# Bug #3671 Stored procedure crash if function has "set @variable=param"

你可能感兴趣的:(mtr Test Case Content-Formatting Guidelines)