프로젝트 구조#

소스코드 #

프로젝트에서 소스는 기본적으로 소스코드(src/main/java)를 가지는 디렉토리와 테스트코드(src/test/java)를 가지는 디렉토리로 나뉜다.

라이브러리#

그리고 소스코드의 품질을 측정하기 위해 사용할 라이브러리(devlib/external)들이 있다.

리포트#

그외 각종 리포팅 데이터를 가질 reports 디렉토리를 가지고 있다.

빌드 스크립트#

build.properties#

project.name=HudsonSample

jarname=hudson-sample.jar

dir.main.java=src/main/java
dir.main.conf=src/main/resources
dir.test.java=src/test/java
dir.test.conf=src/test/resources

dir.web=WebContent
web.classes=WebContent/WEB-INF/classes
dir.app.lib=WebContent/WEB-INF/lib
dir.classes=build
dir.classes.main=${dir.classes}/classes/
dir.classes.test=${dir.classes}/classes/
dir.classes.testclasses=${dir.classes}/testclasses/
dir.classes.instrumentedclasses=${dir.classes}/instrumentedclasses/

devlib=devlib
devlib.external=${devlib}/external/
junit.home=${devlib.external}/junit4.5
emma.home=${devlib.external}/emma-2.0.5312

reports=reports
javadoc=${reports}/javadoc/
junitreports=${reports}/junit/
coveragereports=${reports}/coverage/

javac.debug=true
javac.debug.level=source,lines,vars
javac.encoding=UTF-8

build.xml#

<?xml version="1.0" encoding="UTF-8"?>
<project default="emma" name="HudsonSample" basedir=".">

	<property file="build.properties"/>
	<property environment="env" />
	<property name="catalina.home" value="${env.CATALINA_HOME}" />

	<path id="classpath">
		<pathelement location="${dir.classes.main}" />

		<pathelement path="${catalina.home}/common/lib/servlet-api.jar" />
		<pathelement path="${catalina.home}/common/lib/jsp-api.jar" />

		<fileset dir="WebContent/WEB-INF/lib" includes="**/*.jar" />
		<fileset dir="${emma.home}/lib" includes="**/*.jar" />
		<fileset dir="${junit.home}" includes="**/*.jar" />
	</path>

	<target name="clean">
		<delete dir="${dir.classes.main}" />
		<delete dir="${dir.classes.test}" />
		<delete dir="${dir.classes.testclasses}" />
		<delete dir="${dir.classes.instrumentedclasses}" />

		<delete dir="${junitreports}" />
		<delete dir="${coveragereports}" />

		<delete>
			<fileset dir="${reports}" includes="*.emma"/>
			<fileset dir="${reports}" includes="TEST-*.xml"/>
		</delete>
	</target>

	<taskdef resource="emma_ant.properties" classpathref="classpath" />
	<target name="emma" depends="clean" description="runs the examples">
		<delete file="${reports}/TEST-*.xml" />
		
		<!-- 소스코드 컴파일 -->
		<mkdir dir="${dir.classes.main}" />
		<javac srcdir="${dir.main.java}" 
			destdir="${dir.classes.main}" 
			encoding="${javac.encoding}" 
			deprecation="on" 
			debug="${javac.debug}">
			<classpath refid="classpath" />
		</javac>
		<!-- 테스트코드 컴파일 -->
		<mkdir dir="${dir.classes.test}" />
		<javac srcdir="${dir.test.java}" 
			destdir="${dir.classes.test}" 
			encoding="${javac.encoding}" 
			deprecation="on" 
			debug="${javac.debug}">
			<classpath refid="classpath" />
		</javac>

		<!-- EMMA의 메타데이터를 생성하기 위한 instr 처리 -->
		<emma>
			<instr instrpath="${dir.classes.main}" 
				destdir="${dir.classes.instrumentedclasses}" 
				metadatafile="${reports}/metadata.emma" 
				merge="true">
				<filter value="" />
			</instr>
		</emma>

		<!-- 커버리지 데이터를 만들기 위한 단위테스트 코드 실행 -->
		<junit printsummary="yes" fork="true" haltonfailure="yes">
			<classpath>
				<!-- 
				클래스패스에서 실제 코드의 클래스와 instrument 클래스의 위치를 지정해야 한다.
				주의할 점은 반드시 instrument 클래스의 위치가 실제 코드의 클래스 위치보다 앞서야 한다.
				-->
				<pathelement location="${dir.classes.instrumentedclasses}" />
				<pathelement location="${dir.classes.main}" />
				<fileset dir="${emma.home}/lib" includes="**/*.jar" />
				<fileset dir="${junit.home}" includes="**/*.jar" />
				<fileset dir="WebContent/WEB-INF/lib" includes="**/*.jar" />
			</classpath>
			<jvmarg value="-Demma.coverage.out.file=${reports}/coverage.emma" />
			<jvmarg value="-Demma.coverage.out.merge=false" />
			<formatter type="xml" />
			
			<batchtest todir="${reports}">
				<fileset dir="${dir.classes.main}">
					<include name="**/*Test.class" />
				</fileset>
			</batchtest>
		</junit>

		<!-- 
		앞서 생성한 메타데이터와 커버리지 데이터를 이용해서 EMMA 리포팅 생성
		EMMA 리포팅 생성을 위해서는 메타데이터와 커버리지 데이터가 반드시 존재해야 한다.  
		-->
		<emma>
			<report sourcepath="${dir.main.java}">
				<fileset dir="${reports}">
					<include name="*.emma" />
				</fileset>
				<xml outfile="${coveragereports}/coverage.xml" depth="method" />
			</report>
		</emma>
	</target>
</project>

빌드 실행 로그#

    [javac] Compiling 3 source files to D:\MyLucy\workspace\UNITTEST\HudsonSample\build\classes
    [instr] processing instrumentation path ...
    [instr] instrumentation path processed in 188 ms
    [instr] [6 class(es) instrumented, 0 resource(s) copied]
    [instr] metadata merged into [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\metadata.emma] {in 47 ms}
    [junit] Running kr.or.openframework.hudson.common.CryptographicUtilTest
    [junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.375 sec
    [junit] Running kr.or.openframework.hudson.common.SGMLUtilTest
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.078 sec
    [junit] Running kr.or.openframework.hudson.common.StringHelperTest
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.063 sec
   [report] [emma.Processor::run] complete tool properties:
   [report] coverage.out.file:	[coverage.ec]
   [report] coverage.out.merge:	[true]
   [report] instr.do_suid_compensation:	[true]
   [report] instr.exclude_bridge_methods:	[true]
   [report] instr.exclude_synthetic_methods:	[true]
   [report] metadata.out.file:	[coverage.em]
   [report] metadata.out.merge:	[true]
   [report] report.columns:	[name,class,method,block,line]
   [report] report.depth:	[method]
   [report] report.html.out.encoding:	[ISO-8859-1]
   [report] report.html.out.file:	[coverage/index.html]
   [report] report.metrics:	[method:70,block:80,line:80,class:100]
   [report] report.out.dir:	[D:\MyLucy\workspace\UNITTEST\HudsonSample]
   [report] report.out.encoding:	[UTF-8]
   [report] report.sort:	[+block,+name,+method,+class]
   [report] report.txt.columns:	[class,method,block,line,name]
   [report] report.txt.depth:	[all]
   [report] report.txt.out.file:	[coverage.txt]
   [report] report.units:	[instr]
   [report] report.xml.depth:	[method]
   [report] report.xml.out.encoding:	[UTF-8]
   [report] report.xml.out.file:	[reports/coverage//coverage.xml]
   [report] session.out.file:	[coverage.es]
   [report] session.out.merge:	[true]
   [report] verbosity.level:	[trace1]
   [report] [EMMA v2.0, build 5312 (2005/06/12 19:32:43)]
   [report] input data path:
   [report] {
   [report]   D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\coverage.emma
   [report]   D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\metadata.emma
   [report] }
   [report] source path:
   [report] {
   [report]   D:\MyLucy\workspace\UNITTEST\HudsonSample\src\main\java
   [report] }
   [report] processing input file [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\coverage.emma] ...
   [report] [emma.data.DataFactory::mergeload] [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\coverage.emma]: file length = 225
   [report] [emma.data.DataFactory::mergeload] [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\coverage.emma]: file processed in 0 ms
   [report]   loaded 2 coverage data entries
   [report] processing input file [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\metadata.emma] ...
   [report] [emma.data.DataFactory::mergeload] [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\metadata.emma]: file length = 3956
   [report] [emma.data.DataFactory::mergeload] [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\metadata.emma]: file processed in 0 ms
   [report]   loaded 6 metadata entries
   [report] 2 file(s) read and merged in 0 ms
   [report]   merged metadata contains 6 entries
   [report]   merged coverage data contains 2 entries
   [report] writing [xml] report to [D:\MyLucy\workspace\UNITTEST\HudsonSample\reports\coverage\coverage.xml] ...
   [report]   report: processing package [kr.or.openframework.hudson.common] ...
   [report] [emma.report.xml.ReportGenerator::process] [xml] report generated in 15 ms

리포트 결과#

html#

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
jpg
1.jpg 99.4 kB 2 25-Apr-2009 22:20 DongGukLee
jpg
2.jpg 157.6 kB 2 25-Apr-2009 22:31 DongGukLee
« This page (revision-6) was last changed on 25-Apr-2009 22:32 by DongGukLee