2012-03-07 12 views
14

मैं अपनी परियोजना में चींटी बिल्ड से ग्रैडल में माइग्रेट करने की कोशिश कर रहा हूं। परीक्षण मामलों का एक गुच्छा है (जूनिट.फ्रेमवर्क। टेस्टकेस के उप-वर्ग) और कुछ परीक्षण सूट (जूनिट.फ्रेमवर्क के सबक्लास। टेस्टसुइट)। Gradle स्वचालित रूप से चलाने के लिए सभी परीक्षण मामलों (junit.framework.TestCase के उपclass) उठाया, लेकिन सूट नहीं (junit.framework.TestSuite के subclasses)।जूनिट टेस्टसाइट्स को ग्रेडल से कैसे चलाएं?

मैं शायद इसे चलाने के लिए ant.junit को कॉल करके चारों ओर काम कर सकता हूं। लेकिन, मुझे लगता है कि उन्हें लेने और चलाने के लिए धीरे-धीरे मजबूर करने के लिए एक देशी आसान तरीका होना चाहिए। मुझे दस्तावेज़ में कुछ भी नहीं मिला। क्या मैं कुछ भूल रहा हूँ?

+1

आप खुद का खंडन कर रहे ... आप कह रहे हैं कि 'ग्रैडल ने स्वचालित रूप से सभी परीक्षण मामलों को चलाने के लिए उठाया।' तो समस्या यह है कि यह उन्हें संकलित, लेकिन उन्हें नहीं चलाया? कृपया स्पष्ट करें। –

+0

@c_maker: मैंने स्पष्टता सुधारने के लिए टेक्स्ट संपादित किया है। इंगित करने के लिए धन्यवाद। – James

उत्तर

13

यह मैं यह पता लगाने के लिए मुश्किल था, लेकिन यहाँ एक उदाहरण है:

// excerpt from https://github.com/djangofan/WebDriverHandlingMultipleWindows 
package webdriver.test; 
import http.server.SiteServer; 
import java.io.File; 
import java.io.IOException; 
import org.junit.AfterClass; 
import org.junit.BeforeClass; 
import org.junit.runner.RunWith; 
import org.junit.runners.Suite; 

@RunWith(Suite.class) 
@Suite.SuiteClasses({ TestHandleCacheOne.class, TestHandleCacheThree.class, TestHandleCacheThree.class }) 
public class SuiteOne extends MultiWindowUtils { 

    public static SiteServer fs; 

    @BeforeClass 
    public static void setUpSuiteOne() { 
     File httpRoot = new File("build/resources/test"); 
     System.out.println("Server root directory is: " + httpRoot.getAbsolutePath()); 
     int httpPort = Integer.parseInt("8080"); 
     try { 
      fs = new SiteServer(httpPort , httpRoot); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     initializeBrowser("firefox"); 
     System.out.println("Finished setUpSuiteOne"); 
    } 

    @AfterClass 
    public static void tearDownSuiteOne() { 
     closeAllBrowserWindows(); 
     System.out.println("Finished tearDownSuiteOne"); 
    } 

} 

और एक build.gradle इस के समान:

apply plugin: 'java' 
apply plugin: 'eclipse' 
group = 'test.multiwindow' 

ext { 
    projTitle = 'Test MultiWindow' 
    projVersion = '1.0' 
} 

repositories { 
    mavenCentral() 
} 

dependencies { 
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+' 
    compile group: 'junit', name: 'junit', version: '4.+' 
    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+' 
} 

task testGroupOne(type: Test) { 
    //include '**/*SuiteOne.*' 
    include '**/SuiteOne.class' 
    reports.junitXml.destination = "$buildDir/test-results/SuiteOne") 
    reports.html.destination = "$buildDir/test-results/SuiteOne") 
} 

task testGroupTwo(type: Test) { 
    //include '**/*SuiteTwo.*' 
    include '**/SuiteTwo.class' 
    reports.junitXml.destination = "$buildDir/test-results/SuiteTwo") 
    reports.html.destination = "$buildDir/test-results/SuiteTwo") 
} 
+0

मुझे यह कहना चाहिए कि चूंकि मैंने इस जवाब को पोस्ट किया है क्योंकि यूनिट परीक्षणों को कॉन्फ़िगर करने के लिए डीएसएल थोड़ा बदल गया है। तो, सावधान रहें। – djangofan

संबंधित मुद्दे