He creado una base de datos MySQL importante, con mucha vista, disparadores, funciones y procedimientos.automatización de escenarios de prueba de pepino para MySQL
Es muy difícil de probar y no olvidar nada, así que he escrito Escenarios de pepino para todas las características de mi DB (Insertar, Seleccionar, etc., solicitud de funciones, procedimientos, etc., y vistas)
Esto nos ayuda mucho cuando probamos el comportamiento de todo esto, e incluso antes de escribir vista y otro código, es muy útil para determinar el deseo que realmente queremos hacer.
Mi problema es: después de escribir las características de Cucumber, todos probamos a mano en un shell MySQL.
Soy nuevo en los métodos BDD/TDD y Agile, pero hice algunas búsquedas para saber cómo hacer algo de automatización, pero no encontré nada muy interesante para mi caso.
¿Hay alguien que pueda proporcionar alguna forma interesante de crear automatización para esto?
No sé Ruby, pero con el ejemplo, ¿es posible usar RSPec directamente con MySQL (con algunos ejemplos)?
¡O en otro idioma, o en cualquier solución que se te ocurra!
¡Gracias de antemano!
[EDIT]
Si encontrado algunas cosas interesantes con RSpec y MySQL:
Mysql Support For Cucumber Nagios
Mi problema es: I don' tener cualquier knoledge con Ruby, RSpec, etc.
Estoy trabajando en él con el excelente libro "Pick Axe", y el libro de RSpec PragProg
Pero estaré muy agradecido por un pequeño ejemplo de de RSpec pasos que se indican el código de abajo:
el Procedimiento de 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$$
el C característica ucumber:
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 <texte> for the first parameter
And I have entered <motif> for the second parameter
And I have entered <nb_motif> for the third parameter
And I have entered <positions> for the fourth parameter
When I call prc_liste_motif
Then I should have <out_nb_motif> instead of <nb_motif>
Then I should have <out_positions> instead of <positions>
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 | |
Un exemple de la prueba pasó a mano en 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)
gracias de antemano por su ayuda!
Mi base de datos es muy avanzada, y realmente lo necesito, como cliente (el usuario de la base de datos) para describir el caso de uso y el comportamiento de mi base de datos y pepino encajan perfectamente en la situación. Es importante describir lo que quiero en francés (sí, lo siento, uso Cucumber en francés, no en inglés), pero creo que he encontrado una forma con RSpec con algo como esto https://github.com/garethr/cucumber- nagios/blob/master/lib/generators/project/features/steps/mysql_steps.rb –
Fantástico. Gracias por el puntero - editado para decir "lenguaje natural" ya que creo que ahora hay un gran número de compañías que lo usan en diferentes idiomas. Buena suerte con RSpec y su base de datos. – Lunivore
¿Es malo usar pepino así? Me pareció muy interesante tener una descripción no técnica de un comportamiento esperado: da una documentación muy buena para el código y muchos otros "buenos" en mi opinión ... –