Documentation Home
The MySQL Test Framework, Version 2.0
Download this Manual
PDF (US Ltr) - 0.5Mb
PDF (A4) - 0.5Mb
EPUB - 129.5Kb


The MySQL Test Framework, Version 2.0  /  Writing Test Cases  /  Controlling the Information Produced by a Test Case

4.7 Controlling the Information Produced by a Test Case

By default, the mysqltest test engine produces output only from select, show, and other SQL statements that you expect to produce output (that is, statements that create a result set). It also produces output from certain commands such as echo and exec. mysqltest can be instructed to be more or less verbose.

Suppose that we want to include in the result the number of rows affected by or returned by SQL statements. To do this, add the following line to the test case file preceding the first table-creation statement:

--enable_info

After rerunning the test by invoking mysql-test-run.pl with the --record option to record the new result, the result file will contain more information:

DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
affected rows: 0
CREATE TABLE t2 (Period SMALLINT);
affected rows: 0
INSERT INTO t1 VALUES (9410,9412);
affected rows: 1
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);
affected rows: 4
info: Records: 4  Duplicates: 0  Warnings: 0
SELECT period FROM t1;
period
9410
affected rows: 1
SELECT * FROM t1;
Period  Varor_period
9410    9412
affected rows: 1
SELECT t1.* FROM t1;
Period  Varor_period
9410    9412
affected rows: 1
SELECT * FROM t1 INNER JOIN t2 USING (Period);
Period  Varor_period
9410    9412
affected rows: 1
DROP TABLE t1, t2;
affected rows: 0
ok

To turn off the affected-rows reporting, add this command to the test case file:

--disable_info

In general, options can be enabled and disabled for different parts of the test file. Suppose that we are interested in the internals of the database as well. We could enable the display of query metadata using enable_metadata. With this option enabled, the test output is a bit verbose. However, as mentioned earlier, the option can be enabled and disabled selectively so that it is enabled only for those parts of the test case where it interests you to know more.

If you perform an operation for which you have no interest in seeing the statements logged to the result, you can disable statement logging. For example, you might be initializing a table where you don't really expect a failure, and you are not interested in seeing the initialization statements in the test result. You can use the disable_query_log command to temporarily disable recording of input SQL statements, and enable recording again with enable_query_log. You can disable the recording of the output from executing commands using disable_result_log and enable recording again with enable_result_log.