+ jsunit files in order to run the tests

This commit is contained in:
cbonar 2008-09-20 10:18:21 +00:00
parent 799b0edfdf
commit 3b99410519
7 changed files with 42 additions and 34 deletions

View file

@ -20,9 +20,7 @@
########################################
# Where the source files are : here Maven-style
src.dir=${basedir}/src/main/java
# Where to find resources required at execution time
rc.dir=${basedir}/src/main/resources
src.dir=${basedir}/src/main
# Where to find third party libraries
lib.dir=lib
@ -32,7 +30,7 @@ build.dir=${basedir}/build
classes.dir=${build.dir}/classes
# Where to find the tests sources
tests.dir=${basedir}/src/test/java
tests.dir=${basedir}/src/test
# Where to write the JUnit XML results
tests.logs=${build.dir}/tests-results

View file

@ -42,8 +42,10 @@
<target name="compile" depends="validate" description="Compiles the source code of the project.">
<javac srcdir="${src.dir}" destdir="${classes.dir}" source="1.4">
<src path="${src.dir}" />
<src path="${tests.dir}" />
<src path="${src.dir}/java" />
<src path="${src.dir}/resources" />
<src path="${tests.dir}/java" />
<src path="${tests.dir}/javascript" />
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
@ -54,10 +56,6 @@
<dirset dir="/home/cbonar/src/jsunit/java/bin"/>
<dirset dir="${jsunit.dir}/java/config"/>
<copy todir="${classes.dir}">
<fileset dir="${rc.dir}" />
</copy>
</target>

View file

@ -26,6 +26,7 @@ import net.jsunit.model.Browser;
*/
public class TestLibRunner extends StandaloneTest
{
private TestLibRunnerConfigurationSource configurationSource;

View file

@ -26,17 +26,8 @@ import net.jsunit.configuration.DelegatingConfigurationSource;
* @author http://nicobo.net/contact?subject=jsunit+ant
*/
public class TestLibRunnerConfigurationSource extends
DelegatingConfigurationSource
DelegatingConfigurationSource implements TestLibRunnerParameters
{
/** Name of the property pointing to the JsUnit core library's file */
public static final String PROP_COREJS = "jsunit.coreJs";
/** Name of the property pointing to the JsUnit's <tt>testRunner.html</tt> file */
public static final String PROP_TESTRUNNER = "jsunit.testRunner";
/** Property name defining the Javascript files to include in the test page (path-like). */
public static final String PROP_JAVASCRIPTS = "jsunit.in.javascripts";
/** Property name defining the name of the project to use as the title of the generated page */
public static final String PROP_PROJECT = "jsunit.in.project";
protected static final String PARAM_TESTPAGE = "testPage";
private File testPage = null;

View file

@ -0,0 +1,19 @@
package net.jsunit;
/**
* Describes the system properties recognised by {@link TestLibRunner}.
*
* @author http://nicobo.net/contact?subject=jsunit+ant
*/
public interface TestLibRunnerParameters
{
/** Name of the property pointing to the JsUnit core library's file */
public static final String PROP_COREJS = "jsunit.coreJs";
/** Name of the property pointing to the JsUnit's <tt>testRunner.html</tt> file */
public static final String PROP_TESTRUNNER = "jsunit.testRunner";
/** Property name defining the Javascript files to include in the test page (path-like). */
public static final String PROP_JAVASCRIPTS = "jsunit.in.javascripts";
/** Property name defining the name of the project to use as the title of the generated page */
public static final String PROP_PROJECT = "jsunit.in.project";
}

View file

@ -5,7 +5,6 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Iterator;
@ -15,7 +14,7 @@ import java.util.MissingResourceException;
/**
* This utility class helps building JsUnit (HTML) test pages, giving a list of files to include.
* This utility class helps building JsUnit (HTML) test pages, provided a list of files to include.
*
* @author http://nicobo.net/contact?subject=jsunit+ant
*/
@ -148,10 +147,10 @@ public class TestPage
// Other includes : currently only Javascript is supported
StringBuffer includesBuffer = new StringBuffer();
Collection javascripts = (Collection) includes.get( INCLUDE_JAVASCRIPT );
Collection javascripts = (Collection) getIncludes().get( INCLUDE_JAVASCRIPT );
for ( Iterator itj = javascripts.iterator(); itj.hasNext(); )
{
URI javascript = (URI) itj.next();
String javascript = (String) itj.next();
includesBuffer.append( "<script type=\"text/javascript\" src=\"" );
includesBuffer.append( javascript/*new File( javascripts[i] ).toURI()*/);
includesBuffer.append( "\"></script>\n" );

View file

@ -9,18 +9,20 @@ import junit.textui.TestRunner;
public class TestLibRunnerTest extends TestCase
public class TestLibRunnerTest extends TestCase implements
TestLibRunnerParameters
{
private String urlfail = getClass().getResource( "fail.js" ).toString();
private String urlSuccess1 = getClass().getResource( "success1.js" ).toString();
private String urlSuccess2 = getClass().getResource( "success2.js" ).toString();
private String urlfail;
private String urlSuccess1;
private String urlSuccess2;
protected void setUp() throws Exception
{
System.setProperty( TestLibRunnerConfigurationSource.PROP_PROJECT, getClass().getName() );
// TODO ...
System.setProperty( PROP_PROJECT, getClass().getName() );
System.setProperty( PROP_TESTRUNNER, new File( "/../lib/jsunit/testRunner.html" ).toURI().toString() );
System.setProperty( PROP_COREJS, new File( "/../lib/jsunit/app/jsUnitCore.js" ).toURI().toString() );
urlfail = getClass().getResource( "fail.js" ).toString();
urlSuccess1 = getClass().getResource( "success1.js" ).toString();
urlSuccess2 = getClass().getResource( "success2.js" ).toString();
@ -34,26 +36,26 @@ public class TestLibRunnerTest extends TestCase
System.setProperty( TestLibRunnerConfigurationSource.PARAM_TESTPAGE, urlfail );
TestLibRunner test = new TestLibRunner( new TestLibRunnerConfigurationSource() );
TestResult result = TestRunner.run( test );
assert (result.failureCount() > 0 && result.errorCount() == 0);
assertTrue( result.failureCount() > 0 && result.errorCount() == 0 );
// succeeds if the test succeeds
System.setProperty( TestLibRunnerConfigurationSource.PARAM_TESTPAGE, urlSuccess1 );
test = new TestLibRunner( new TestLibRunnerConfigurationSource() );
result = TestRunner.run( test );
assert (result.failureCount() == 0 && result.errorCount() == 0);
assertTrue( result.failureCount() == 0 && result.errorCount() == 0 );
// fails if at least one test fails
System.setProperty( TestLibRunnerConfigurationSource.PARAM_TESTPAGE, urlfail
+ File.pathSeparator + urlSuccess1 );
test = new TestLibRunner( new TestLibRunnerConfigurationSource() );
result = TestRunner.run( test );
assert (result.failureCount() > 0 && result.errorCount() == 0);
assertTrue( result.failureCount() > 0 && result.errorCount() == 0 );
// succeeds if no test fails
System.setProperty( TestLibRunnerConfigurationSource.PARAM_TESTPAGE, urlSuccess1
+ File.pathSeparator + urlSuccess2 );
test = new TestLibRunner( new TestLibRunnerConfigurationSource() );
result = TestRunner.run( test );
assert (result.failureCount() == 0 && result.errorCount() == 0);
assertTrue( result.failureCount() == 0 && result.errorCount() == 0 );
}
}