Monday, March 12, 2012

Code Coverage Results


Code coverage results for the examples discussed in the Accurate programming  by Prof.Veronica Gaspes, Prof.Rex Page, Prof. Walid Taha







Sunday, March 4, 2012

Unit Testing- Scala Code Coverage Tool - SCCT -SBT- ScalaCheck- Ubuntu 11.10


Credit goes to the original publishers...
http://mtkopone.github.com/scct/
I modified or organized the original content...

After Creating a New Project now its time for the Code Coverage Analysis setup using the SCCT. All the instructions about the SCCT setup were given by the original publisher. I would like to give you a detailed step level setup explanation which makes your path easy for setup.
Set up for SCCT tool.
1. Create plugins folder as shown in below image.





Add the following code to project\plugins\Plugins.scala


import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
  val scctRepo = "scct-repo" at "http://mtkopone.github.com/scct/maven-repo/"
 lazy val scctPlugin = "reaktor" % "sbt-scct-for-2.8" % "0.1-SNAPSHOT"
}  





2. Project definition \project\build\MyFirstProject.scala , should extent reaktor.scct.ScctProject


import sbt._
import reaktor.scct.ScctProject
class AnilsProject(info: ProjectInfo) extends DefaultProject(info) with ScctProject
{
lazy val hi=task {println("This is Anils First New Project"); None}
}



3. Enter in to the project directory
4. Type sbt and press enter


5. Type reload and press enter (necessary only when code is changed or some new files added)
 6. Type update and  press enter(only when code is changed or some new files added)


7. Type run and press enter.


8. Type test-coverage and press enter
if everything goes fine you see below output


Surprising, Its says that there are no tests to run. Its right we did not write any code for test until now.
9. Add the below code to the file project/build/MyFirstProject.scala
val scalaTest = "org.scalatest" % "scalatest" % "1.2"
  val scalaCheck = "org.scala-tools.testing" % "scalacheck_2.8.0" % "1.7"

10. Update source code  src/main/scala
11. Update source code for test in src/test/scala


12. now go to terminal type , reload and enter, update and enter
13. Type test-coverage and press enter.


14. To check the test output open /target/scala_2.8.1/coverage-report/index.html



 

It wasted me a lot of time in setting up the interface to run simple tests. there is no any written manual for the new bees to guide through the process. This struggle with all these setup inspired me to present a guide for the persons who are new to use Scala, SBT, ScalaCheck, SCCT,  




enjoy.....







Creating a new project and its definition in SBT - Ubuntu 11.10

Credit goes to the original publishers...
I modified or organized the original content...
Before creating a new project the sbt  should be setup to launch it from any directory. To do it follow the [2-5] for Ubuntu 11.10



1. Choose your own directory to create a new project
2. Using Terminal, enter into the directory where you planned to create a new project
3. Type sbt into the terminal, if the sbt launch is set properly, you see the below image content



4.It will ask you, create a new project? (y/N/s)  Type y and press enter

5. The project has been successfully created, you can check it by visiting the directory where you created the new project, You could see the four folders as shown in the right side of the top image.

6. let us start with an example code, to test if our new project works fine. Copy the below code to the directory  src\main\scala

   object Anil{
         def main(args:Array[String]){
           println("\n\n Hello Anil, You program has been successfully Executed \n\n ")
         } 
    }





7. From Terminal go to directory
8. Type sbt and press enter.
9. Type reload and press enter.
10.Type update and press enter.
11. Type run and press enter.
If everything goes fine you could see the output displayed in blow image 


12. Configure sbt by creating project definition using a scala file in to the directory  project\build\MyFirstProject.scala

import sbt._
class AnilsProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val hi=task {println("This is Anils First New Project"); None}
}





13. Type hi in command prompt, you will see...



By now, You know how to create a new project, configure SBT by creating a project definition, program an example in Scala and successfully execute it.
Good Luck with the rest.
enjoy the rest of your journey with Scala using SBT

Saturday, March 3, 2012

Unit Testing- Scala Code Coverage Tool - SCCT Windows 7


Credit goes to the original publishers...
http://mtkopone.github.com/scct/
I modified or organized the original content...

After Creating a New Project now its time for the Code Coverage Analysis setup using the SCCT. All the instructions about the SCCT setup were given by the original publisher. I would like to give you a detailed step level setup explanation which makes your path easy for setup.
Set up for SCCT tool.
1. Add the following code to (In my case) C:\Users\anil\anil\project\plugins\Plugins.scala


import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
  val scctRepo = "scct-repo" at "http://mtkopone.github.com/scct/maven-repo/"
 lazy val scctPlugin = "reaktor" % "sbt-scct-for-2.8" % "0.1-SNAPSHOT"
}  


2. Project definition(Inmycase)  C:\Users\anil\anil\project\build\AnilFirstProject.scala , should extent reaktor.scct.ScctProject


import sbt._
import reaktor.scct.ScctProject
class HelloAnilProject(info: ProjectInfo) extends DefaultProject(info) with ScctProject
{
lazy val hi=task {println("This is Anils First New Project"); None}
}


3. Enter in to the project directory (In my case) c:\Users\anil\anil\
4. Type sbt and press enter
5. Type reload and press enter (necessary only when code is changed or some new files added)
6. Type update and  press enter(only when code is changed or some new files added)
7. Type test-coverage and press enter.
if everything goes fine you see below output
8. To check the test output open /target/scala_2.9.1/coverage-report/index.html

enjoy.....






Creating a new project and its definition in SBT - Windows 7

Credit goes to the original publishers...
I modified or organized the original content...
Before creating a new project the sbt  should be setup to launch it from any directory. To do it follow the [2-5] for Windows 7



1. Choose your own directory to create a new project
2. Using Command prompt, enter into the directory where you planned to create a new project
3. Type sbt at the command prompt, if the sbt launch is set properly, you see the below image content in the command prompt

4.It will ask you, create a new project? (y/N/s)  Type y and press enter
5. The project has been successfully created, you can check it by visiting the directory where you created the new project, you could see  the folder that you can see in the below image.
6. let us start with an example code, to test if our new project works fine. Copy the below code to the directory (In my case) C:\Users\anil\anil\src\main\scala

   object Anil{
         def main(args:Array[String]){
           println("\n\n Hello Anil, You program has been successfully Executed \n\n ")
         } 
    }

7. From command prompt go to directory (In my case) c:\Users\anil\anil
8. Type sbt and press enter.
9. Type relosd and press enter.
10.Type update and press enter.
11. Type run and press enter.
If everything goes fine you could see the output displayed in blow image 

12. Configure sbt by creating project definition using a scala file in to the directory (In my case) c:\Users\anil\anil\project\build\AnilFirstProject.scala

import sbt._
class HelloAnilProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val hi=task {println("This is Anils First New Project"); None}
}


13. Type hi in command prompt, you will see...

By now, You know how to create a new project, configure SBT by creating a project definition, program an example in Scala and successfully execute it.
Good Luck with the rest.
enjoy the rest of your journey with Scala using SBT

Sunday, February 26, 2012

Acumen Development Setup in Windows 7

Credit goes to the Original publishers
http://code.google.com/p/simple-build-tool/
http://code.google.com/p/acumen-language/
All the below existing content are the modified and organised content of the above original publishers

Important: Versions of Java, Scala and SBT, check the image below, click it to enlarge...
Instructions for Setup:
1. Download acumen-10.12.13.zip , Extract and rename it to acumen for easy access from command promt
2. Download sbt-launch-0.7.4.jar , and rename it to to sbt-launch.jar. Make sure that Java is already installed and set to path
3. Create a batch file sbt.bat and paste the below code to sbt.bat
set SCRIPT_DIR=%~dp0
java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %*

 4. Place the sbt.bat and sbt-launch.jar files in same folder
5. Put sbt.bat on path, so that you can launch sbt in any directory by entering sbt from command prompt

6. Open Command Prompt and enter in to the acumen/sources, see image below
8. Now launch SBT by entering sbt from the acumen/sources directory , see image below...
9. Type reload and press enter in the command prompt, see image below...
10. Type update and press enter in the command prompt, see image below ....

11. Type run and press enter in the command prompt, if everything goes fine like me, now you see the compiled and run acumen output, see image below...




Saturday, February 25, 2012

Acumen Development Setup In Ubuntu 11.10


Credit goes to the Original publishers
http://code.google.com/p/simple-build-tool/
http://code.google.com/p/acumen-language/
All the below existing content are the modified and organised content of the above original publishers


Important: Notice the versions of Java 1.6.0_26, scala 2.7.7 and sbt 0.7.4 used for Acumen
Instructions for Development setup:

  1.  Download the Acumen-10.12.13.zip , extract and rename it to acumen for easy access from terminal.
  2. Download sbt-launch-0.7.4.jar and rename it to sbt-launch.jar.
  3. Write the below script to a file to run the jar
      Hint: gedit from terminal open text editor, copy the above script and save it as sbt
    java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar `dirname $0`/sbt-launch.jar "$@"
  4. Make the script in sbt file executable
    Hint :
    anil@ubuntu:~$ chmod u+x ~/bin/sbt
  5. Place the sbt-launch.jar and sbt files to bin
    Hint: use the below commands from the location file, I used Home directory
    anil@ubuntu:~$ sudo mv sbt-launch.jar /bin
    anil@ubuntu:~$ sudo mv sbt /bin
  6. In the terminal, enter in to the acumen/sources
    anil@ubuntu:~$ cd acumen/sources
  7. Launch sbt from acumen/sources as shown below
    anil@ubuntu:~/acumen/sources$ sbt
  8. Enter reload from terminal
    > reload
  9. Enter update from terminal
    > update
  10. Enter run from terminal
    > run


If everything goes fine you see the below output as shown in image
Click the blow image to enlarge: