JUnit: A critical look JUnit: Una mirada crítica
As a model of XP development (done at a few thousand feet above ground) I was expecting a solid bug free transperant code for JUnit. Como un modelo de desarrollo XP (hecho en unos mil pies sobre el suelo) yo estaba esperando una sólida libre de bugs transperant código para JUnit.
I noticed few interesting bugs & surprising features in the code. He observado algunos bugs interesantes y sorprendentes características en el código.
If you want to increase your test count (possibly for your manager who checks the tests written or for your customer) by a factor x (without actually performing the tests) then just override the default implementation of countTestCases() to return x. Si desea aumentar su prueba count (posiblemente por su gerente controles que las pruebas escritas o de su cliente) por un factor x (sin llegar a efectuar las pruebas), sólo por defecto anular la aplicación de countTestCases () para volver x. The documentation says “Counts the number of test cases executed by run(TestResult result)”. La documentación dice "Cuenta el número de casos de prueba ejecutados por ejecutar (TestResult resultado)". However in reality it always returns 1. Sin embargo, en realidad, que siempre devuelve 1.
If you have 10 test cases in your Test class and if you return 20 in your impl. Si hay 10 casos de prueba en los ensayos de su clase y si devuelve 20 en su Ejec. of countTestCases() then the total test count is shown as 200. de countTestCases () entonces el total de pruebas contar se muestra como 200. However in reality only 10 tests are run. Sin embargo, en realidad, sólo el 10 pruebas se ejecutan.
The code has interesting tests performed on a TestCase subclass like it checks that there is at least one method with name starting with test (could be just test() ). El código tiene interesantes pruebas realizadas en una subclase de TestCase como los controles que hay al menos un método con el nombre empezando con la prueba (puede ser de prueba ()). It checks that there is a public constructor which accepts a string as parameter. Se comprueba que existe un constructor público que acepta una cadena como parámetro. It could still do nothing. Podría todavía no hacen nada.
These are interesting ideas half-baked which feels forced on the user, specially when you decide to override the default implementation to hook it to your test generator. Estas son ideas interesantes de medio horno que se siente obligado por el usuario, especialmente cuando usted decide anular la aplicación por defecto para engancharlo a su generador de prueba. Also you might have noticed that the error messages are often not very illuminating when the cons is missing. También usted habrá notado que los mensajes de error que a menudo no son muy esclarecedoras las desventajas cuando se pierde.
The code does this funny passing back and forth with run variants between TestCase & TestResults for no apparent reason before finally calling testBare. El código lo hace divertido de pasar hacia adelante y hacia atrás con ejecutar variantes entre TestCase y TestResults sin motivo aparente hasta que finalmente se pide testBare. Methods like runProtected or run variants belong to TestCase. Métodos como runProtected o ejecutar variantes pertenecen a TestCase. At the least lets keep the run methods in one class instead of calling each other back and forth. Al menos permite mantener la carrera en los métodos de una clase en lugar de llamar a cada uno hacia adelante y hacia atrás.
Filed under Filed under Java Software El software de Java , Technology Tecnología | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Enviar artículo
You may also like to read También puede leer |





August 10th, 2004 at 4:50 am 10 de Agosto, 2004 a las 4:50 am
Take a look at TestNG: Eche un vistazo a TestNG: http://beust.com/testng
August 10th, 2004 at 11:28 am 10 de Agosto, 2004 a las 11:28 am
The design assumes you implement Test, and that’s all. El diseño asume que la aplicación de los ensayos, y eso es todo. However, it provides _convenience_ methods (such as TestCase) that allow you to write Tests with a minimum of fuss. Sin embargo, se prevé _convenience_ métodos (como TestCase) que le permiten escribir los ensayos con un mínimo de esfuerzo.
Yes, it’s not overly defensive: it makes the assumption that the developer is trying to use it, not abuse it. Sí, no es excesivamente defensiva: se hace la hipótesis de que el promotor está tratando de usarla, no abusar de él.
If you look at the lifecycle of the tests, BTW, you’ll see why the run method is passed back and forth. Si nos fijamos en el ciclo de vida de las pruebas, BTW, verás por qué correr el método se pasa hacia atrás y hacia adelante.
August 11th, 2004 at 3:40 am Agosto 11, 2004 a las 3:40 am
Take a look at TestNG, Eche un vistazo a TestNG, http://beust.com/testng
August 11th, 2004 at 4:57 am Agosto 11, 2004 a las 4:57 am
“their user stories didn’t foresee it” — that’s it. "Sus historias de usuario no preveía" - eso es todo. Kent Beck’s JUnit was written to certain (probably not documented) specifications and assumptions. Kent Beck's JUnit fue escrito a ciertas (probablemente no documentadas) las especificaciones y las hipótesis. It actually works well for its intended purposes, though there is a Smalltalk flavor to it that someone who came to Java from other languages would not appreciate. En realidad funciona bien para sus fines, aunque hay un sabor de Smalltalk a considerar que alguien que vino a Java de otros idiomas que no apreciamos.
I expect that TestSuite() overrides countTestCases() appropriately… but the framework is not written to prevent people from abusing it, since that would get in the way of people who need to extend it for legitimate reasons. Espero que testsuite () invalida countTestCases () adecuadamente… pero el marco no está escrito para evitar que la gente de abusar de él, ya que obtendría en el camino de la gente que necesita ampliarla por razones legítimas.
I suspect that “TestResults” is following the Smalltalk idiom of a “collecting parameter” (see Kent Beck’s book “Smalltalk Best Practice Patterns”. Tengo la sospecha de que "TestResults" está siguiendo el lenguaje Smalltalk de una "recopilación de parámetro" (véase Kent Beck's libro "Smalltalk Best Practice Patterns".