Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit e377915

Browse files
author
Guillermo Lengemann
committed
Translated Chapter 7
1 parent d3d80cc commit e377915

File tree

1 file changed

+87
-89
lines changed

1 file changed

+87
-89
lines changed

src/incomplete-and-skipped-tests.rst

Lines changed: 87 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,51 @@
22

33
.. _incomplete-and-skipped-tests:
44

5-
============================
6-
Incomplete and Skipped Tests
7-
============================
5+
=============================
6+
Omisión y Pruebas Incompletas
7+
=============================
88

99
.. _incomplete-and-skipped-tests.incomplete-tests:
1010

11-
Incomplete Tests
12-
################
11+
Pruebas Incompletas
12+
###################
1313

14-
When you are working on a new test case class, you might want to begin
15-
by writing empty test methods such as:
14+
Cuando estamos trabajando con una nueva clase para un caso de prueba, podríamos
15+
querer comenzar a escribir una método de prueba vacío de la siguiente manera:
1616

1717
.. code-block:: php
1818
1919
public function testSomething()
2020
{
2121
}
2222
23-
to keep track of the tests that you have to write. The
24-
problem with empty test methods is that they are interpreted as a
25-
success by the PHPUnit framework. This misinterpretation leads to the
26-
test reports being useless -- you cannot see whether a test is actually
27-
successful or just not yet implemented. Calling
28-
``$this->fail()`` in the unimplemented test method
29-
does not help either, since then the test will be interpreted as a
30-
failure. This would be just as wrong as interpreting an unimplemented
31-
test as a success.
32-
33-
If we think of a successful test as a green light and a test failure
34-
as a red light, we need an additional yellow light to mark a test
35-
as being incomplete or not yet implemented.
36-
``PHPUnit_Framework_IncompleteTest`` is a marker
37-
interface for marking an exception that is raised by a test method as
38-
the result of the test being incomplete or currently not implemented.
39-
``PHPUnit_Framework_IncompleteTestError`` is the
40-
standard implementation of this interface.
41-
42-
:numref:`incomplete-and-skipped-tests.incomplete-tests.examples.SampleTest.php`
43-
shows a test case class, ``SampleTest``, that contains one test
44-
method, ``testSomething()``. By calling the convenience
45-
method ``markTestIncomplete()`` (which automatically
46-
raises an ``PHPUnit_Framework_IncompleteTestError``
47-
exception) in the test method, we mark the test as being incomplete.
23+
para mantener el control de las pruebas que hemos escrito. El problema con
24+
los métodos de prueba vacíos es que son interpretados como exitosos por
25+
el framework PHPUnit. Este error en la interpretación lleva a que el reporte
26+
de la prueba sea inútil, porque no podemos ver si la prueba fue realmente
27+
exitosa o solo no está implementada. Llamar a ``$this->fail()`` en un
28+
método de prueba no implementado no es de ayuda, pues, la prueba será
29+
interpretada como una falla. Lo que sería tan incorrecto como interpretar
30+
una prueba no implementada como exitosa.
31+
32+
Si pensamos en una luz verde para una prueba exitosa y una luz roja para una
33+
prueba fallida, necesitamos una luz adicional de color amarillo para marcar
34+
una prueba como incompleta o aún no implementada.
35+
``PHPUnit\Framework\IncompleteTest`` es una interfaz de marcado para indicar
36+
un excepción que lanza el método de prueba cuando la prueba está
37+
incompleta o actualmente no está implementada.
38+
La clase ``PHPUnit\Framework\IncompleteTestError`` es la implementación estándar
39+
de esta interfaz.
40+
41+
El :numref:`incomplete-and-skipped-tests.incomplete-tests.examples.SampleTest.php`
42+
muestra una clase para un caso de prueba, ``SampleTest``, que contiene un
43+
método de prueba ``testSomething()``. Mediante el llamado del método
44+
``markTestIncomplete()`` (que lanza automáticamente una excepción
45+
``PHPUnit\Framework\IncompleteTestError``) en el método de prueba, conseguimos
46+
marcar la prueba como incompleta.
4847

4948
.. code-block:: php
50-
:caption: Marking a test as incomplete
49+
:caption: Marcar una prueba como incompleta
5150
:name: incomplete-and-skipped-tests.incomplete-tests.examples.SampleTest.php
5251
5352
<?php
@@ -66,11 +65,10 @@ exception) in the test method, we mark the test as being incomplete.
6665
);
6766
}
6867
}
69-
?>
7068
71-
An incomplete test is denoted by an ``I`` in the output
72-
of the PHPUnit command-line test runner, as shown in the following
73-
example:
69+
Una prueba incompleta se denota con una ``I`` en la salida del ejecutor de
70+
pruebas en línea de comandos de PHPUnit, como se muestra en el siguiente
71+
ejemplo:
7472

7573
.. code-block:: bash
7674
@@ -90,40 +88,42 @@ example:
9088
OK, but incomplete or skipped tests!
9189
Tests: 1, Assertions: 1, Incomplete: 1.
9290
93-
:numref:`incomplete-and-skipped-tests.incomplete-tests.tables.api`
94-
shows the API for marking tests as incomplete.
91+
En la :numref:`incomplete-and-skipped-tests.incomplete-tests.tables.api`
92+
se muestra la API para marcar las pruebas como incompletas.
9593

9694
.. rst-class:: table
97-
.. list-table:: API for Incomplete Tests
95+
.. list-table:: API para Pruebas Incompletas
9896
:name: incomplete-and-skipped-tests.incomplete-tests.tables.api
9997
:header-rows: 1
10098

101-
* - Method
102-
- Meaning
99+
* - Método
100+
- Propósito
103101
* - ``void markTestIncomplete()``
104-
- Marks the current test as incomplete.
102+
- Marca la prueba actual como incompleta.
105103
* - ``void markTestIncomplete(string $message)``
106-
- Marks the current test as incomplete using ``$message`` as an explanatory message.
104+
- Marca la prueba actual como incompleta usando un mensaje, ``$message``,
105+
explicativo.
107106

108107
.. _incomplete-and-skipped-tests.skipping-tests:
109108

110-
Skipping Tests
111-
##############
109+
Omitir las pruebas
110+
##################
112111

113-
Not all tests can be run in every environment. Consider, for instance,
114-
a database abstraction layer that has several drivers for the different
115-
database systems it supports. The tests for the MySQL driver can of
116-
course only be run if a MySQL server is available.
112+
No todas la pruebas se pueden ejecutar en cualquier entorno. Consideremos por
113+
ejemplo, una capa de abstracción de base de datos que tiene varios controladores
114+
para los diferentes sistemas de base de datos soportados. Las pruebas para
115+
un controlador MySQL se pueden ejecutar solamente, por supuesto, si un servidor
116+
MySQL está disponible.
117117

118-
:numref:`incomplete-and-skipped-tests.skipping-tests.examples.DatabaseTest.php`
119-
shows a test case class, ``DatabaseTest``, that contains one test
120-
method, ``testConnection()``. In the test case class'
121-
``setUp()`` template method we check whether the MySQLi
122-
extension is available and use the ``markTestSkipped()``
123-
method to skip the test if it is not.
118+
El :numref:`incomplete-and-skipped-tests.skipping-tests.examples.DatabaseTest.php`
119+
muestra una clase para un caso de prueba, ``DatabaseTest``, que contiene un
120+
método de prueba, ``testConnection()``. En el método modelo ``setUp()`` de la
121+
clase de caso de prueba revisamos si la extensión MySQLi está disponible y
122+
usamos el método ``markTestSkipped()`` para saltar la prueba si no está
123+
disponible la extensión.
124124

125125
.. code-block:: php
126-
:caption: Skipping a test
126+
:caption: Omitir la prueba
127127
:name: incomplete-and-skipped-tests.skipping-tests.examples.DatabaseTest.php
128128
129129
<?php
@@ -145,11 +145,10 @@ method to skip the test if it is not.
145145
// ...
146146
}
147147
}
148-
?>
149148
150-
A test that has been skipped is denoted by an ``S`` in
151-
the output of the PHPUnit command-line test runner, as shown in the
152-
following example:
149+
Una prueba que se omite se denota con una ``S`` en la salida del ejecutor de
150+
pruebas en línea de comandos de PHPUnit, como se muestra en el siguiente
151+
ejemplo:
153152

154153
.. code-block:: bash
155154
@@ -169,65 +168,66 @@ following example:
169168
OK, but incomplete or skipped tests!
170169
Tests: 1, Assertions: 0, Skipped: 1.
171170
172-
:numref:`incomplete-and-skipped-tests.skipped-tests.tables.api`
173-
shows the API for skipping tests.
171+
En la :numref:`incomplete-and-skipped-tests.skipped-tests.tables.api`
172+
se muestra la API para omitir pruebas.
174173

175174
.. rst-class:: table
176-
.. list-table:: API for Skipping Tests
175+
.. list-table:: API para omitir pruebas
177176
:name: incomplete-and-skipped-tests.skipped-tests.tables.api
178177
:header-rows: 1
179178

180-
* - Method
181-
- Meaning
179+
* - Método
180+
- Propósito
182181
* - ``void markTestSkipped()``
183-
- Marks the current test as skipped.
182+
- Marca la prueba actual como omitida.
184183
* - ``void markTestSkipped(string $message)``
185-
- Marks the current test as skipped using ``$message`` as an explanatory message.
184+
- Marca la prueba actual como omitida usando un mensaje, ``$message``, de
185+
explicación.
186186

187187
.. _incomplete-and-skipped-tests.skipping-tests-using-requires:
188188

189-
Skipping Tests using @requires
190-
##############################
189+
Omitir pruebas usando @requires
190+
###############################
191191

192-
In addition to the above methods it is also possible to use the
193-
``@requires`` annotation to express common preconditions for a test case.
192+
A parte de los métodos de arriba es posible usar la anotación ``@requires``
193+
para expresar precondiciones comunes para un caso de prueba.
194194

195195
.. rst-class:: table
196-
.. list-table:: Possible @requires usages
196+
.. list-table:: Posibles usos para @requires
197197
:name: incomplete-and-skipped-tests.requires.tables.api
198198
:header-rows: 1
199199

200-
* - Type
201-
- Possible Values
202-
- Examples
203-
- Another example
200+
* - Tipo
201+
- Posibles Valores
202+
- Ejemplos
203+
- Otros Ejemplos
204204
* - ``PHP``
205-
- Any PHP version identifier
205+
- Cualquier identificador de versión de PHP
206206
- @requires PHP 5.3.3
207207
- @requires PHP 7.1-dev
208208
* - ``PHPUnit``
209-
- Any PHPUnit version identifier
209+
- Cualquier identificador de versión de PHPUnit
210210
- @requires PHPUnit 3.6.3
211211
- @requires PHPUnit 4.6
212212
* - ``OS``
213-
- A regexp matching `PHP_OS <http://php.net/manual/en/reserved.constants.php#constant.php-os>`_
213+
- Una expresión regular que coincida con `PHP_OS <http://php.net/manual/es/reserved.constants.php#constant.php-os>`_
214214
- @requires OS Linux
215215
- @requires OS WIN32|WINNT
216216
* - ``OSFAMILY``
217-
- Any `OS family <http://php.net/manual/en/reserved.constants.php#constant.php-os-family>`_
217+
- Cualquier valor de `Familia de SO <http://php.net/manual/es/reserved.constants.php#constant.php-os-family>`_
218218
- @requires OSFAMILY Solaris
219219
- @requires OSFAMILY Windows
220220
* - ``function``
221-
- Any valid parameter to `function_exists <http://php.net/function_exists>`_
221+
- Cualquier parámetro valido para `function_exists <http://php.net/function_exists>`_
222222
- @requires function imap_open
223223
- @requires function ReflectionMethod::setAccessible
224224
* - ``extension``
225-
- Any extension name along with an optional version identifier
225+
- Cualquier nombre de extensión junto con un identificador de versión opcional
226226
- @requires extension mysqli
227227
- @requires extension redis 2.2.0
228228

229229
.. code-block:: php
230-
:caption: Skipping test cases using @requires
230+
:caption: Omitir casos de pruebas usando @requires
231231
:name: incomplete-and-skipped-tests.skipping-tests.examples.DatabaseClassSkippingTest.php
232232
233233
<?php
@@ -248,9 +248,7 @@ In addition to the above methods it is also possible to use the
248248
249249
// ... All other tests require the mysqli extension
250250
}
251-
?>
252-
253-
If you are using syntax that doesn't compile with a certain PHP Version look into the xml
254-
configuration for version dependent includes in :ref:`appendixes.configuration.testsuites`
255-
256251
252+
Si estamos usando una sintaxis que no copila con una determinada versión de PHP
253+
es conveniente revisar la dependencia de versiones en la configuración xml
254+
que se incluye en :ref:`appendixes.configuration.testsuites`.

0 commit comments

Comments
 (0)