Posts

Showing posts with the label Templates

Basic ANT build file Template

It happens all of the time, I want to write a new ANT build file, I don't really remember how to begin, so, I just copy a working build file and then I start removing most of its content. Well, that's not so productive and is a bad practice in general, so for the benefit of all (me included), I've decided doing the same process for the last time, in order to create a basic Ant template file from which I will be able to begin each time. This template contains only the most basic Ant build file. Basic example which shows how to: Create a basic Ant build file. Usage of a property. Usage of a Target (Method / Procedure). Dependency of targets. <?xml version="1.0" encoding="ISO-8859-1"?> <project name="BasicTemplate" default="all"> <property name="distribution" value="${basedir}/dist" /> <target name="init" description="Some initialization acts which should run at the begining"...

JUnit 4 Template Class

Each time I want to create a JUnit test class, I take a look at an older one, copy it, then remove all of the specifics of the previous tests. That isn't a good practice  :-) So I've decided to do it once more, in order to create a template - a working JUnit class which doesn't do anything, just add your specific code you want to test and run along: package org.chaiavi.TestJunit; import java.io.IOException; import org.junit.*; import static org.junit.Assert.*; public class TestJunit{ /** Use this method for all of the lines of code you want to run before the whole JUnit Class. */ @BeforeClass     public static void unitSetup() throws Exception { } /** Use this method for all of the lines of code you want to run after the whole JUnit Class. */ @AfterClass     public static void unitCleanup() throws Exception {     }  /** Use this method for all of the lines of code you want to run before each JUnit test. */ @Before     public void methodSetup() throws Exception ...