Showing posts with label animal testing. Show all posts
Showing posts with label animal testing. Show all posts

Thursday, January 14, 2010

Cobertura - Ignore Logger Calls

I recently caught the testing bug and try to make sure that all the code I write is well tested and has 100% coverage. I use Cobertura, which is an excellent tool for measuring how much of your code is covered by tests. The coverage report it produces shows you what percentage of packages, classes, methods, lines and conditionals are covered and it highlights, in red, the lines in your source code which are not covered. I can now sleep better at night, knowing that my code is fully covered!

In order to use Cobertura, you just need to add the plugin to your project's POM file. When I first ran Cobertura, I found that it highlighted my logger.debug lines of code, so I had to tell it to ignore all logger calls, as follows:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <formats>
            <format>html</format>
        </formats>
        <instrumentation>
            <ignores>
                <ignore>org.apache.log4j.*</ignore>
            </ignores>
        </instrumentation>
    </configuration>
    <executions>
        <execution>
            <phase>deploy</phase>
            <goals>
                <goal>cobertura</goal>
            </goals>
        </execution>
    </executions>
</plugin>
You can run it using mvn cobertura:cobertura and then look at the report in target/site/cobertura/index.html.

Cobertura will also highlight some code which is impossible to test. For example, if a class has a private constructor (because it has static methods), then it will highlight the private constructor, even though you can't test it (unless you use reflection and change the constructor's accessibility, but that is going a bit too far!).

Monday, June 30, 2008

Skip Tests in Maven [Tip]

If your tests are failing and you can't be bothered to fix them, this handy tip will show you how you can skip tests and build your Maven project straightaway!

Simply add the property -Dmaven.test.skip=true to your Maven command. Here is an example:

mvn -Dmaven.test.skip=true install

The compiler will not compile the test sources and will not run your JUnit tests:

[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.

But of course, your test classes should always run, right?

Reference:
http://maven.apache.org/general.html

Sunday, January 28, 2007

Is Animal Testing Justified?

Every year thousands of animals die at the hands of curious scientists. Before they die, they are routinely burned, scalded, poisoned, starved, given electric shocks, addicted to medicines, subjected to near freezing temperature, dozed with radioactive elements, driven insane, deliberately inflicted with diseases such as AIDS, cancer, herpes etc. Their brains and spinal cord are damaged since the use of anaesthesia is rarely administrated.

Despite all this cruelty, not a single disease has been cured through vivisection in the previous century. More than a million medicines are marketed each year after undergoing the unreliable test methods still in use: vivisection. Two of the most famous tests are the Draize or eye irritancy test and the LD50, lethal dose 50. The Draize test is performed on albino rabbits because they are cheap, docile and do not have tear ducts so as to wash away the chemicals. The substances put in the eye varies from mascara to aftershave. Reactions include ulcers, inflammation and rupture of the eyeball and bleeding. LD50 refers to the lethal dose required to kill 50% of the test species. There is also LD100... ironically of human poisoning.

Some medicines pass safe in case of animals but can prove to be very harmful in humans such as Opren: 3500 people suffered side effects as well as damage to skin, eyes, kidneys and livers. Clinoquenil, another medicine, led to the loss of eyesight. In the same way, many drugs harmful to animals can be beneficial to humans such as penicillin, an antibiotic to humans but killed guinea pigs and common aspirin caused birth defects in mice and rats. Skin irritancy tests differ from species to species for example nicotine is lethal at 9.2mg/kg in dogs and 53mg/kg in rats and 0.9mg/kg in humans (PETA fact sheet). This is proof that animal testing is unreliable but, unfortunately, these sadistic tests will go on every day.

We are cutting down forests which provide shelter to these animals, dump toxic chemicals and sewage in the waters in which they live, where the tusks and fur of the last few of their species and pour cosmetics into their eyes to determine the harmful side effects they might cause to humans.

Animals possess the same kind and of feelings and emotions that humans do and without anaesthesia, they are subjected to unbearable pain which eventually leads to their ill-fated and gruesome death. We fail to give animals the respect and rights which they deserve and treat them as lifeless unfeeling scientific specimens.

Other methods for testing products can be practised which are accurate, less time consuming and less expensive. These include cell and cultures which hold no capacity for pain, less animals better planned work and computer models to answer questions and guide research .If animal testing is totally eliminated, it would free 6.8 billion dollars which can be used for educational processes and health care. Thus, more than 30 million people can be helped who cannot afford health.

[Taken from: Fahd Shariff's Essays Page, Dated Sep, 1999]