Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Testes Unitários Verificar a funcionalidade de partes do sistema. Boas práticas para testes: Evitar redundância; Permitir que todos os possíveis caminhos sejam cobertos com vários testes; Encontrar erros ainda não descobertos. XUnit Provê estrutura de testes unitários. Conceito de testes automatizados. Exemplos: SUnit: SmallTalk; CPPUnit: C++; PHPUnit, PHP; Dunit: Delphi; JUnit: Java. JUnit Popularidade Facilidade em seu uso Keep the bar green to keep the code clean... Example JUnit: Annotations @BeforeClass @Before @BeforeClass public static void onlyOnce(){ } @Before public void setup() { } @Test @Test public void verifyName() { } JUnit: Assert A set of assertion methods useful for writing tests. Only failed assertions are recorded. These methods can be used directly: Assert. assertEquals(...) But they read better if they are referenced through static import: import static org.junit.Assert.*; Attributes: [message], expected, actual, [delta]* * for double JUnit: Assert main methods static void assertEquals static void assertNotEquals static void assertNull static void assertNotNull static void assertFalse static void assertTrue fail(java.lang.String message) EasyMock Easy Mock: What is it? EasyMock provides Mock Objects for interfaces in JUnit tests by generating them on the fly using Java's proxy mechanism. Due to EasyMock's unique style of recording expectations, most refactorings will not affect the Mock Objects. So EasyMock is a perfect fit for Test-Driven Development. EasyMock is open source software available under the terms of the MIT license. Development and downloads are hosted on SourceForge. Why mock it? Unit testing is the testing of software units in isolation. However, most units do not work alone, but they collaborate with other units. To test a unit in isolation, we have to simulate the collaborators in the test. A Mock Object is a test-oriented replacement for a collaborator. It is configured to simulate the object that it replaces in a simple way. In contrast to a stub, a Mock Object also verifies whether it is used as expected. DBUnit DBUnit: What is it? DbUnit is a JUnit extension (also usable with Ant) targeted for database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to fail or exacerbate the damage. DbUnit has the ability to export and import your database data to and from XML datasets. Since version 2.0, DbUnit can works with very large dataset when use in streaming mode. DbUnit can also helps you to verify that your database data match expected set of values. EMMA A free Java code coverage tool EMMA: what is it? EMMA is an open-source toolkit for measuring and reporting Java code coverage. EMMA distinguishes itself from other tools by going after a unique feature combination: support for large-scale enterprise software development while keeping individual developer's work fast and iterative at the same time. Every developer on your team can now get code coverage for free and they can get it fast! EMMA is so lightweight developers can use it during the process of writing tests instead of waiting for a "test build". This gets code coverage where it belongs: helping with design and implementation before the code is checked in. Example Cruise Control Continuous Integration Cruise Control: What is it? CruiseControl is a framework for a continuous build process. It includes, but is not limited to, plugins for email notification, Ant, and various source control tools. A web interface is provided to view the details of the current and previous builds. CruiseControl is distributed under a BSDstyle license and is free for use. CruiseControl adheres to an open source model and therefore makes the source code freely available. References http://*.sf.net