mysql场景测试_自动化MySQL的Cucumber测试场景

我已经构建了一个重要的

MySQL数据库,包含很多视图,触发器,函数和过程.

很难测试,也不会忘记任何事情,因此,我为我的数据库的所有功能编写了Cucumber场景(插入,选择等,请求函数,程序等,以及视图)

当我们测试所有这些的行为时,这对我们有很大帮助,甚至在编写视图和其他代码之前,确定我们真正想做的事情是非常有帮助的.

我的问题是:在编写Cucumber功能之后,我们都在MySQL Shell中手动测试.

我是BDD / TDD和敏捷方法的新手,但我已经做了一些搜索,知道如何进行一些自动化,但对于我的情况没有发现任何有趣的东西.

是否有人可以提供一些有趣的方法来为此创建自动化?

我不知道Ruby,但举个例子,是否有可能直接使用RSPec与MySQL(有一些例子)?

或者用其他语言或任何您能想到的解决方案!

提前致谢!

[编辑]

如果在RSpec和MySQL中找到一些有趣的东西:

我的问题是:我对Ruby,RSPec等没有任何知识.

我正在使用优秀的“Pick Axe”书和PragProg的RSPec书来完成它

但鉴于以下代码,我将非常感谢RSpec步骤的一个小例子:

MySQL程序

DELIMITER $$

CREATE PROCEDURE `prc_liste_motif` (

IN texte TEXT,

IN motif VARCHAR(255),

OUT nb_motif INT(9),

OUT positions TEXT)

BEGIN

DECLARE ER_SYNTAXE CONDITION FOR SQLSTATE '45000';

DECLARE sousChaine TEXT;

DECLARE positionActuelle INT(9) DEFAULT 1;

DECLARE i INT(9) DEFAULT 1;

IF

LENGTH(motif) > LENGTH(texte)

THEN

SIGNAL ER_SYNTAXE

SET MESSAGE_TEXT =

'Bad Request: Le motif est plus long que le texte.',

MYSQL_ERRNO = 400;

END IF;

SET positions = '';

SET nb_motif = 0;

REPEAT

SET sousChaine = SUBSTRING_INDEX(texte, motif, i);

SET positionActuelle = LENGTH(sousChaine) + 1;

IF

positionActuelle < LENGTH(texte) + 1

THEN

IF

LENGTH(positions) > 0

THEN

SET positions = CONCAT(positions, ',');

END IF;

SET positions = CONCAT(positions, positionActuelle);

SET nb_motif = nb_motif + 1;

END IF;

SET i = i + 1;

UNTIL LENGTH(sousChaine) >= LENGTH(texte)

END REPEAT;

END$$

黄瓜特色:

Feature: Procedure prc_liste_motif

In order to precess a string according to a given unit

I want to know the number of units present in the chain and their positions

Knowing that the index starts at 1

Background: the database mydatabase in our SGBDR server

Given I have a MySQL server on 192.168.0.200

And I use the username root

And I use the password xfe356

And I use the database mydatabase

Scenario Outline: Using the procedure with good values in parameters

Given I have a procedure prc_liste_motif

And I have entered for the first parameter

And I have entered for the second parameter

And I have entered for the third parameter

And I have entered for the fourth parameter

When I call prc_liste_motif

Then I should have instead of

Then I should have instead of

Exemples:

| texte | motif | nb_motif | positions | out_nb_motif | out_positions |

| Le beau chien | e | | | 3 | 2,5,12 |

| Allo | ll | | | 1 | 2 |

| Allo | w | | | 0 | |

在MySQL中手动通过测试的例子:

$mysql -h 192.168.0.200 -u root -p xfe356

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> USE mydatabase

Database changed

mysql> SET @texte = 'Le beau chien';

Query OK, 0 rows affected (0.00 sec)

mysql> SET @motif = 'e';

Query OK, 0 rows affected (0.00 sec)

mysql> SET @nb_motif = NULL;

Query OK, 0 rows affected (0.00 sec)

mysql> SET @positions = NULL;

Query OK, 0 rows affected (0.00 sec)

mysql> SET @out_nb_motif = 3;

Query OK, 0 rows affected (0.00 sec)

mysql> SET @out_positions = '2,5,12';

Query OK, 0 rows affected (0.00 sec)

mysql> CALL prc_liste_motif(@texte, @motif, @nb_motif, @positions);

Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @nb_motif = @out_nb_motif AND @positions = @out_positions;

+-----------------------------------------------------------+

| @nb_motif = @out_nb_motif AND @positions = @out_positions |

+-----------------------------------------------------------+

| 1 |

+-----------------------------------------------------------+

1 row in set (0.00 sec)

在此先感谢您的帮助 !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值