TestRunner.class
java.lang.ClassNotFoundException: TestRunner.class
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
当我在eclipse中运行它时,Junit测试工作,但是当我通过ant(通过eclipse或终端运行)运行它们时失败;他们每个都抛出以下异常:
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class JsoupTest {
public static void main(String argv[]) throws IOException {
Document doc = Jsoup.connect("http://www.ebay.co.uk/sch/Action-Figures/246/bn_1632128/i.html").get();
for(int i = 2; i<11;i++){
Element category = doc.getElementById("w"+i); // select section with id = w2 , w3, w4 ...
if(!category.select("div.b-module-carousel__title").isEmpty()){
System.out.println(category.select("div.b-module-carousel__title").text()); // the title of the section is either here
}
else{
System.out.println(category.select("div.b-block-list__header").text()); // or here
}
Elements items = category.select("li");
for(Element e : items){
System.out.println( e.select("div.b-block-info-container__title").text()
// to get prices or trending-prices
// (some boolean expression which can be true or false)?return this if true:return this part if false
+ " || " + ((!e.select("div.b-block-info-container__price").isEmpty())?e.select("div.b-block-info-container__price").text():(e.select("div.b-block-info-container__trending-prices-group").text()))
+ " || " + e.select("div.item_quantity__hotness").text()
+ " || " + e.select("a").attr("href"));
}
System.out.println("************************************************************************************"); // just added to separate the categories
}
}
}