Wednesday, April 13, 2011

Groping Western Chikan

Unit Tests (CLASS)

First, what are the unit tests?
are tests designed to test java classes in isolation and are related to the code and
responsibility of each class and its most critical pieces of code.

Why unit testing?
• Ensures quality of code delivered. It's the best way to detect errors early in the development
. However, this does not guarantee to detect all errors in both integration and acceptance testing are still needed.
• Help to define the requirements and responsibilities of each method in each class
tested.
• It is good how to run proof of concept. When it is necessary to test concepts
without integrating unit tests using a method
becomes effective.
• Allows early in code refactoring. It is not necessary
a cycle of integration for refactoring in the application, just to see how it
test case for refactoring unit of the kind that we are testing in question.
• Allows for stress testing even earlier in the code.
For example, a method that performs a SQL query that exceeds the time of acceptance can optimize
before integrating with the application. • Allows
find errors or bugs early in development.
It has been proved that the earlier errors are corrected, the less it costs to fix them.

In the previous image sequence has to be followed in a program to perform these tests, first we have the class under test (Class Under Test) This test will test functional or "black box" .
The process of a black box test is simple, run the unit test data and the output is observed, compared with the result expected. If the test is satisfied, ie the results obtained and expected are equal, we call it "oracle."
As we get past the black-box testing we can determine that "quantity" of code we've covered, that is, the percentage of code have executed. These are white box testing.
With white box testing we are looking to find fragments of the program are not executed by test cases.
If we find that the results of these tests is less than 100%, we run other cases for up to 100%. If it still does not get that 100%, we should ask what it's worth the piece of code.

To perform unit tests in Java usually uses the JUnit tool.

junit Here the link: http://www.junit.org/
Para descargar JUnit https://github.com/KentBeck/junit/downloads https://github.com/KentBeck/junit/downloads recomiendo descarguen el primero que viene ahí junit4.9b2.zip Sample ya que ese contiene ejemplos con los que podemos realizar las pruebas.

Al descargar, nos posecionamos en la terminal en la dirección dónde está contenido el junit4.9b2.zip lo descomprimimos y configuramos el path entrando a .bashrc y al final ponemos la dirección en la que se encuentra el junit-4.9b2 -src.


Aquí adjunto 2 capturas de pantalla where you access the . bashrc, configure the path, and run the tests one of the examples.



Reference Links:
http://www.informatizando.es/?p=24
http:/ / blog.continuum.cl/wp-content/uploads/2008/08/pruebas-unitarias.pdf

0 comments:

Post a Comment