Sunday, February 12, 2012

Unit Testing with ANT

Here I'm going to talk about how to write the XML code for Unit testing with ANT,

 <target name="compile" description="Compile Classes">
        <javac srcdir="${src}" destdir="${target}"/>
 </target>

In the above target, it compiles the source files from the ${src} and store them in the ${target}

<path id="test.classpath">
        <pathelement path="${test}"/>
        <pathelement path="${libs}/JUnit.jar"/>
        <pathelement path="${target}"/>
</path>
Here there are certain type of paths that you should introduce to the junit tests in ANT to run.
  1. ${test} : where your test classes are stored
  2. ${libs}/JUnit.jar : where your jUnit.jar is stored
  3. ${target} : where your compiled classes are stored
  <target name="compile-test" depends="compile" description="Compile Test Classes">
            <javac srcdir="${test}" verbose="true">
            <classpath refid="test.classpath"/>
        </javac>
 </target>
This particular target compiles the test classes to make them ready to run. The refid (means reference ID) here points to the paths mentioned above

    <target name="test-run" depends="compile-test" description="Run Test Cases">       
        <junit printsummary="yes" haltonfailure="yes" showoutput="yes" >
            <classpath refid="test.classpath"/>
            <batchtest fork="yes" todir="${test}">
                <formatter type="xml"/>
                <fileset dir="${test}">
                    <include name="**/*Test*.java"/>
                </fileset>
            </batchtest>
        </junit>
    </target>
 This is the test-run target, meaning this is where the test is run. All you need to understand is when selecting the fileset, I've selected all the test classes but you can limit them here.
If you've read through this simple tutorial, you should get a good understanding of how unit testing works. You can dig into more by following the link below.

If you need more details on ANT :

Saturday, February 4, 2012

Bumblebee 3.0 for Ubuntu 12.10,12.04 and 11.10

The bumblebee project has successfully released an 'optimus replacement' for the linux platform. The latest bumblebee version was released on January 19,2012, Bumblebee 3.0 . It is very stable and enhances the performance of Ubuntu 11.10 thus allowing Unity 3d to be used.
it provides, automatic power management which also survives suspend and a greater battery time.
But as Bumblebee requires low level hardware access, you can't test this on a Virtual Machine

Installing Bumblebee

first, if you haven't already installed the restricted drivers for the Nvidia GPU, do,

sudo apt-get purge nvidia-current  // this will update the GPU drivers

Then open the terminal and add ppa Bumbleebe ”Tumbleweed”, then install

sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update 
sudo apt-get install bumblebee 
 
To allow you to use Bumblebee (replace $user with your username)
sudo usermod -a -G bumblebee $user
 
Now it's all done, restart the computer and then you can test it,
run
glxspheres

and run
optirun glxspheres

Then observe the difference. Now you can enjoy Unity 3d, in fact Ubuntu boots right into it when it was restarted.