0 Replies Latest reply: Apr 13, 2012 12:58 PM by mlindsayea RSS

    source-path mismatch problem

    mlindsayea Community Member

      I'm trying to integrate unit testing with our build process and failing with the following error message.

       

      BUILD FAILED

      C:\Projects\project\client\FUTest\build.xml:88: Compilation failed: Warning: Source path entry, 'C:\Projects\project\client\FUTest\src\tests', is a subdirectory of source path entry, 'C:\Projects\project\client\FUTest\src'.

      C:\Projects\project\client\FUTest\src\tests\SampleCase.as: Error: A file found in a source-path must have the same package structure '', as the definition's package, 'tests'.

      C:\Projects\project\client\FUTest\src\tests\SampleSuite.as: Error: A file found in a source-path must have the same package structure '', as the definition's package, 'tests'.

       

      I realize that my project structure does not match the sampleCIProject but I'm trying to fit this into an existing project that also does not match.

       

      Here's the structure

       

      FUTest/src/main/FlexUnitApplication.as

       

      package main
      {
           public class FlexUnitApplication extends Sprite
           {
                public function FlexUnitApplication()
                {
                     onCreationComplete();
                }
                
                private function onCreationComplete():void
                {
                     var testRunner:FlexUnitTestRunnerUIAS=new FlexUnitTestRunnerUIAS();
                     testRunner.portNumber=8765; 
                     this.addChild(testRunner); 
                     testRunner.runWithFlexUnit4Runner(currentRunTestSuite(), "FUTest");
                }
                
                public function currentRunTestSuite():Array
                {
                     var testsToRun:Array = new Array();
                     testsToRun.push(Request.methods(SampleCase,["simpleAdd"]));
                     
                     return testsToRun;
                }
           }
      }
      

       

      FUTest/src/main/FlexUnitCompilerAppliaction.as

       

      package main
      {
           import flash.display.Sprite;
           import tests.SampleCase;
           import tests.SampleSuite;
      
           public class FlexUnitCompilerApplication extends Sprite
           {
                private var tests_SampleCase_obj:SampleCase;
                private var tests_SampleSuite_obj:SampleSuite;
           }
      }
      

      FUTest/src/test/SampleSuite.as

      package tests
      {
           [Suite]
           [RunWith("org.flexunit.runners.Suite")]
           public class SampleSuite
           {
                public var t1:SampleCase;
           }
      }
      

       

      FUTest/src/test/SampleCase.as

       

      package tests
      {
           import flexunit.framework.Assert;
      
           public class SampleCase
           {
                [Test(description="My First Actionscript Unit Test")]
                public function simpleAdd():void
                {
                     var x:int = 5 + 3;
                     Assert.assertEquals( 8, x );
                }
           }
      }
      

       

      FUTest/build.xml

      <?xml version="1.0" ?>

       

      <project name="flex unit test" default="info">

       

          <property file="build.properties" />

          <taskdef resource="flexTasks.tasks" classpath="${FLEX_SDK_DIR}/flexTasks.jar" />

       

          <target name="info" description="flex unit test">

              <tstamp />

              <echo message="============================================"/>

              <echo message="flex unit test"/>

              <echo message="============================================"/>

          </target>

       

       

          <!-- GLOBAL SETTINGS -->

         

          <property name="FLEX_HOME" value="${FLEX_SDK_DIR}/${FLEX_COMPILER_VERS}" />

          <property name="EXT_LIBS" value="../ExternalLibraries" />

       

       

          <taskdef resource="flexUnitTasks.tasks">

              <classpath>

                  <fileset dir="${EXT_LIBS}">

                      <include name="flexUnitTasks*.jar" />

                  </fileset>

              </classpath>

          </taskdef>

       

          <!-- PROJECT SETTINGS -->

         

          <property name="FU_TEST" value="FUTest" />

          <property name="SRC_FU_TEST" value="${basedir}/src" />

          <property name="OUT_FU_TEST" value="${basedir}/bin/FUTest.swf" />

         

          <property name="TEST_DIR" value="${basedir}/src/tests" />

          <property name="OUTPUT_DIR" value="${basedir}/target" />

          <property name="BIN_DIR" value="${OUTPUT_DIR}/bin" />

          <property name="REPORT_DIR" value="${OUTPUT_DIR}/report" />

          <property name="DIST_DIR" value="${OUTPUT_DIR}/dist" />

         

         

       

          <target name="compile" description="Build the FU Test Project" depends="init">

              <echo message="Compiling..." />

             

              <exec executable="${FLEX_HOME}/${MXMLC}" failonerror="true">

                  <arg line="-compiler.include-libraries=${EXT_LIBS}/flexunit-4.1.0-8-as3_4.1.0.16076.swc" />

                  <arg line="-compiler.include-libraries=${EXT_LIBS}/hamcrest-as3-flex-1.1.3.swc" />

                  <arg line="-compiler.include-libraries=${EXT_LIBS}/flexunitextendedAS.swc" />

                  <arg line="-compiler.include-libraries=${EXT_LIBS}/FlexUnitTestRunner_rb.swc" />

                  <arg line="-compiler.incremental=true" />

                  <arg line="-debug=${debug}" />

                  <arg line="-default-background-color=${background.color}" />

                  <arg line="-default-frame-rate=${framerate}" />

                  <arg line="-default-size ${width} ${height}" />

                  <arg line="-source-path='${SRC_FU_TEST}'" />

                  <arg line="'${SRC_FU_TEST}/FUTest.as'" />

                  <arg line="-o=${OUT_FU_TEST}" />

                  <arg line="-use-network=true" />

                  <arg line="-static-link-runtime-shared-libraries=true" />

              </exec>

          </target>

       

          <target name="init">

              <!-- Create directories needed for the build process -->

              <mkdir dir="${OUTPUT_DIR}" />

              <mkdir dir="${BIN_DIR}" />

              <mkdir dir="${REPORT_DIR}" />

              <mkdir dir="${DIST_DIR}" />

          </target>

       

       

          <target name="test" depends="compile">

         

              <echo message="Running Tests..." />

             

              <!-- Execute FlexUnit tests and publish reports -->

              <flexunit

               workingDir="${BIN_DIR}"

               toDir="${REPORT_DIR}"

               haltonfailure="false"

               verbose="true"

               localTrusted="true">

                  <source dir="${SRC_FU_TEST}" />

             

                  <testSource dir="${TEST_DIR}">

                      <include name="**/*.as" />

                  </testSource>

                  <library dir="${EXT_LIBS}" />

              </flexunit>

             

              <!-- Generate readable JUnit-style reports -->

              <junitreport todir="${REPORT_DIR}">

                  <fileset dir="${REPORT_DIR}">

                      <include name="TEST-*.xml" />

                  </fileset>

                  <report format="frames" todir="${REPORT_DIR}/html" />

              </junitreport>

          </target>

       

       

      </project>

       

      The initial complile seems works fine and produes bin/FUTest.swf.  So why does the flexunit compile fail?

       

      Any help most appreciated.

       

      Thanks,

      - mlindsay