Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant.

Similar presentations


Presentation on theme: "Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant."— Presentation transcript:

1 Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant

2 Fall 2007CS 2252 Eclipse command line arguments

3 Fall 2007CS 2253 Debugging in Eclipse

4 Fall 2007CS 2254 JUnit Testing JUnit is an open-source testing framework for Java You can create test cases and test suites by extending the appropriate class from the JUnit package

5 Fall 2007CS 2255 JUnit Testing JUnit has been integrated into Eclipse Make sure junit.jar is on the build path –use the Properties menu –or let Eclipse find it when you create the test case Create a test case –File -> New -> JUnit Test Case Run your application as a JUnit Test

6 Fall 2007CS 2256 In the TestCase class Write methods that test each of the methods of your class –use the assertion methods on next slide for testing results of methods You can override setup() and teardown() to create a set of objects to be shared by several tests

7 Fall 2007CS 2257 Assertion methods assertEquals( expected, actual) assertFalse( condition), assertTrue(condition) assertNull( object), assertNotNull( object) assertSame( ecpected, actual), assertNotSame(expected, actual) And many more

8 Fall 2007CS 2258 Sources of Information The home page for JUnit is at http://www.junit.org/ The documentation is at http://junit.sourceforge.net/javadoc/

9 Fall 2007CS 2259 Building Big Projects For very large projects, the process of recompiling all the modules that make up the project can take a long time. One way to reduce the amount of time needed to build a project is to only recompile the modules that have not changed and don't use modules that have changed. Two tools that determine what needs to be recompiled. –make –ant (for Java)

10 Fall 2007CS 22510 The make Utility make is a command generator designed to help you manage large projects –make allows you to specify dependencies between modules if a class depends on another class, it should be recompiled when that class changes –make allows you to specify how to compile a particular class –make uses these specifications to determine the minimum amount of work needed to recompile a program

11 Fall 2007CS 22511 How does make Work? make uses a file called Makefile (or makefile or GNUMakefile) to determine what needs to be recompiled. The makefile contains a set of rules for executing the jobs it can be asked to do. When you run make, it uses the rules in the makefile to determine what needs to be done. make does the minimum amount of work needed to get the job done.

12 Fall 2007CS 22512 The Makefile A make file consists of a set of rules Each rule has the form target: dependencies commands target is (usually) the name of a file to be created dependencies are the names of files that are needed to create the target commands is one or more commands that need to be executed to create the target. Each command is indented with a tab

13 Fall 2007CS 22513 Example TestPriorityQueue uses KWPriorityQueue. PrintDocument and ComparePrintDocuments objects ComparePrintDocuments uses PrintDocument objects KWPriorityQueue implements Queue

14 Fall 2007CS 22514 makefile TestPriorityQueue.class: TestPriorityQueue.java \ KWPriorityQueue.class PrintDocument.class \ ComparePrintDocuments.class javac TestPriorityQueue.java KWPriorityQueue.class: KWPriorityQueue.java Queue.class javac KWPriorityQueue.java Queue.class: Queue.java javac Queue.java

15 Fall 2007CS 22515 makefile (cont.) ComparePrintDocuments.class: \ ComparePrintDocuments.java PrintDocument.class javac ComparePrintDocuments.java PrintDocument.class: PrintDocument.java javac PrintDocument.java

16 Fall 2007CS 22516 Dummy targets The makefile can also have targets that don’t create files A target to run a java program TestPriorityQueue: TestPriorityQueue.class java TestPriorityQueue A target to remove class files clean: rm -f *.class

17 Fall 2007CS 22517 Sources of Information Managing Projects with make by Andrew Oram and Steve Talbot http://www.delorie.com/gnu/docs/make/ make_toc.htmlhttp://www.delorie.com/gnu/docs/make/ make_toc.html Look at the man page man make

18 Fall 2007CS 22518 Ant make can be used with Java files ant was designed for building large Java projects –acronym for "Another Neat Tool" Ant uses XML format for build files

19 Fall 2007CS 22519 build files A build file is an xml file that contains exactly one project element main is target to build if none is given name and basedir are optional attributes for project

20 Fall 2007CS 22520 Targets A project element contains one or more targets Each target corresponds to a task –the main target is required depends attribute contains list of targets that this target needs

21 Fall 2007CS 22521 Tasks Each target contains one or more tasks There are a number of built-in tasks –java needs the classname attribute to be set to the main class –javac –jar - to create a java archive –javadoc - to create the documentation

22 Fall 2007CS 22522 Sources of Information Ant The Definitive Guide by Steve Holzner Ant is an open source Apache project –http://ant.apache.org/http://ant.apache.org/


Download ppt "Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant."

Similar presentations


Ads by Google