Note that there are some explanatory texts on larger screens.

plurals
  1. POGradle - Java - tests - java.lang.AssertionError Assertion Error
    primarykey
    data
    text
    <p>Running a gradle build.</p> <p>Compile works fine but getting an error during :test task i.e. test(s) failed.</p> <p><strong>Output is:</strong></p> <pre><code>com.tr.ids.biz.domain.TestAttributeDescriptorBeanProvider &gt; testGetAttributeHandler FAILED java.lang.AssertionError at TestAttributeDescriptorBeanProvider.java:65 com.tr.ids.biz.domain.TestAttributeDescriptorBeanProvider &gt; testGetSpringBeanWithExp FAILED java.lang.AssertionError at TestAttributeDescriptorBeanProvider.java:60 com.tr.ids.biz.domain.pvt.dao.TestRdbmsDAOFactory &gt; testCreateDAO FAILED java.lang.AssertionError at TestRdbmsDAOFactory.java:90 83 tests completed, 3 failed :test FAILED </code></pre> <p>If you see the first 2 failed tests, it's failing for Java fail() and the source code Java file snapshot for those lines is (ignore the line# as i have used can -n command). Line # 60 and 65 are giving the error. I have tried joining line# 60+61+62 in one line as line#60, same error while gradle build:</p> <p>-bash-3.2$ cat -n test/java/com/tr/ids/biz/domain/TestAttributeDescriptorBeanProvider.java | egrep " *6[0-9]|70"</p> <pre><code>60 fail(BASE_NAME + ": Failed in 'setUp()' method: " 61 + exp.getMessage() 62 + exp.getCause()); 63 } catch (SvcMockLibException exp) { 64 65 fail(BASE_NAME + ": Failed in 'setUp()' method: " 66 + exp.getMessage() 67 + exp.getCause()); 68 } 69 70 } </code></pre> <p>-bash-3.2$</p> <p>Similarly, 2nd file for line# 90 (showing lines 90,91,92 below) is failing and contains the following code:</p> <pre><code>assertEquals( "Test1: Returned bean is not instance of RdbmsAttributeDescriptorDAO", true, flag); </code></pre> <p>Any idea, why assertEquals() and fail () are failing.</p> <p>The same source code when compiled with ANT, works and doesn't give these errors.</p> <h2>ANT code performing the Unit testing part is:</h2> <pre><code> &lt;!-- Execute the UNIT tests --&gt; &lt;target name="test-junit" depends="init,classpaths,classpath-junit,compile-junit" &gt; &lt;property name="test.junit.reports" value="junit-test-reports" /&gt; &lt;delete dir="${test.junit.reports}" /&gt; &lt;mkdir dir="${test.junit.reports}" /&gt; &lt;mkdir dir="${test.junit.reports}/xml" /&gt; &lt;junit printsummary="yes" haltonfailure="no" failureproperty="build.test.failure" &gt; &lt;batchtest todir="${test.junit.reports}/xml" &gt; &lt;fileset dir="${build.junit.classes}"&gt; &lt;include name="**/Test*.class" /&gt; &lt;/fileset&gt; &lt;/batchtest&gt; &lt;classpath&gt; &lt;pathelement path="${test-junit.classpath}" /&gt; &lt;/classpath&gt; &lt;formatter type="xml" /&gt; &lt;/junit&gt; &lt;junitreport todir="${test.junit.reports}" &gt; &lt;fileset dir="${test.junit.reports}/xml" &gt; &lt;include name="TEST*.xml" /&gt; &lt;/fileset&gt; &lt;report format="frames" todir="${test.junit.reports}/html" /&gt; &lt;/junitreport&gt; &lt;fail if="build.test.failure" message="*** JUnit test cases did not pass. ***" /&gt; &lt;/target&gt; &lt;!-- Setup classpath for JUnit tests --&gt; &lt;target name="classpath-junit" depends="init" &gt; &lt;property name="build.src.java-junit" value="${build.home}/test/java" /&gt; &lt;property name="build.src.rsrc-junit" value="${build.home}/test/resources" /&gt; &lt;property name="build.junit.classes" value="${build.dest}/junit/classes" /&gt; &lt;path id="test-junit.classpath"&gt; &lt;path location="${build.junit.classes}" /&gt; &lt;path location="${build.dest.classes}" /&gt; &lt;path refid="build.classpath" /&gt; &lt;path location="${build.src.conf}" /&gt; &lt;path location="${build.home}" /&gt; &lt;path location="${build.src.rsrc-junit}" /&gt; &lt;/path&gt; &lt;property name="test-junit.classpath" refid="test-junit.classpath" /&gt; &lt;/target&gt; &lt;!-- Compile the JUnit source code --&gt; &lt;target name="compile-junit" depends="init,classpaths,classpath-junit,compile" &gt; &lt;delete dir="${build.junit.classes}"/&gt; &lt;mkdir dir="${build.junit.classes}"/&gt; &lt;javac destdir="${build.junit.classes}" debug="true" debuglevel="lines,vars,source" optimize="false" deprecation="${build.compiler.deprecation}"&gt; &lt;classpath&gt; &lt;path refid="build.classpath" /&gt; &lt;path refid="test-junit.classpath" /&gt; &lt;/classpath&gt; &lt;src path="${build.src.java-junit}"/&gt; &lt;/javac&gt; &lt;/target&gt; </code></pre> <p><strong>Note</strong>: When I tried ANT based target for another project, both ANT / Gradle failed at the unit tests thus, ANT code does fail the tests for some projects which fail in Gradle as well. But the case I have given above runs fine in ANT and fails in Gradle "gradle clean build" step (where build also calls :test task).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload