Friday 15 June 2012

java - Trouble Running simple JUnit Test through Ant on eclipse -


I have the following juneet test in Eclipse:

  Package testing; Import org.junit.Test; Public square simpleJuynette test {@Test Public Zero () {System.out.println ("Tested"); }}  

and the following build.xml in the same folder:

  & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Name of the project = "loggerast" default = "junket test" = "." & Gt; & Lt; Goal Name = "JUnitTest" & gt; & Lt; JUnit & gt; & Lt; Classpath location = "../../ lib / junit.jar" /> & Lt; Test name = "test.SimpleJUnitTest" /> & Lt; / JUnit & gt; & Lt; Echo & gt; Bu & lt; / Echo & gt; & Lt; / Target & gt; & Lt; / Project & gt;  

If I run a test class under "Run as ..." and selects JUnit, it runs without error. If I run Build.xml under "Run edge ..." and select the ant build then I get the following output:

  Buildfile: C: \ Users \ 995868 \ workspace \ JUnit1 \ Tst \ Test \ build.xml JUnitTest: [junit] Test Test. SimpleJunetTest failed [Echo] Boo Boo succeeded Total time: 390 milliseconds  

If I remove the classpath attribute under Janet, then I have a different error about the necessity of junior jar on classpath Message, so I think that using JUnate I can not understand what its error is here. I have tried to load the class to a system.out.println () by inserting static block code in class, and it does not appear, so it seems that I'm doing Am I wrong in the configuration

Can anyone tell me what is wrong here?

Edit:

  Directory structure: Genus1 - Bean - Test - SimpleUnited Test - Lib --junit.jar --scripts --build.xml - Src - tst - test --SimpleJUnitTest.java  

I also copied build.xml to TST and participated in that directory from the command line, the same result.

I have copied% ant_home% \ lib to junit.jar without any effect, though, when I took the fourth class out of the orbit, I got the message "Including Junit. Should not, if not in the ant of its ant "I'm not sure where" ant's own square "is specified. A class path block with a new error message is:

  & lt; Classpath & gt; & Lt; Pathelement location = "c: /users/995868/apache-ant-1.9.4/lib" /> & Lt; Pathhelp location = "../bin" /> & Lt; / Classpath & gt;  

I am not using the Hamstrist feature anywhere, so I have not seen it and have put it. I was trying to make a simple example, at least not mentioned) that hamkelst is necessary.

I think you are missing hamcrest-

Edit: and you are missing the test file class from your classpath. You will need to update your classmap in the following way:

  & lt; Classpath & gt; & Lt; Pathhelp location = "bin" /> & Lt ;! - This is your test class - & gt; & Lt; Pathelement location = "lib / hamcrest-core-1.3.jar" /> & Lt; Pathelement location = "lib / junit-4.12.jar" /> & Lt; / Classpath & gt;  

No comments:

Post a Comment