दो विकल्प हैं, एक मेवेन समाधान और एक निश्चित समाधान। कम से कम युग्मित समाधान pre-integration-test
और post-integration-test
चरण में प्लगइन निष्पादित करना है। Introduction to the Build Lifecycle - Lifecycle Reference देखें। मैं ग्रिजली से परिचित नहीं हूँ, लेकिन यहाँ एक उदाहरण का उपयोग करते हुए घाट है:
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<contextPath>/xxx</contextPath>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
ध्यान दें कि start
के लिए चरण pre-integration-test
और stop
post-integration-test
है। मुझे यकीन नहीं है कि कोई ग्रिज़ली मेवेन प्लगइन है, लेकिन आप इसके बजाय maven-antrun-plugin का उपयोग कर सकते हैं।
दूसरा विकल्प एक जुनीट RunListener का उपयोग करना है। RunListener
इस तरह के परीक्षण शुरू, परीक्षण अंत, परीक्षण की विफलता, परीक्षण सफलता आदि
public class RunListener {
public void testRunStarted(Description description) throws Exception {}
public void testRunFinished(Result result) throws Exception {}
public void testStarted(Description description) throws Exception {}
public void testFinished(Description description) throws Exception {}
public void testFailure(Failure failure) throws Exception {}
public void testAssumptionFailure(Failure failure) {}
public void testIgnored(Description description) throws Exception {}
}
के रूप में की घटनाओं, परीक्षण करने के लिए तो तुम RunStarted और RunFinished को सुन सके और सुनता है। ये आपकी इच्छित सेवाओं को शुरू/बंद कर देंगे। फिर, अचूक में, आप एक कस्टम श्रोता, निर्दिष्ट कर सकते हैं का उपयोग कर:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>com.mycompany.MyResultListener,com.mycompany.MyResultListener2</value>
</property>
</properties>
</configuration>
</plugin>
यह Maven Surefire Plugin, Using JUnit, Using custom listeners and reporters
स्रोत
2013-02-08 12:33:29
सकें कि आप अगर JUnit नहीं प्रयोग कर रहे हैं से है? – TheWhiteRabbit
यदि आप पीओजेओ या टेस्टएनजी परीक्षण का उपयोग कर रहे हैं तो आप @BeforeClass – TheWhiteRabbit
@TechExchange का उपयोग कर सकते हैं यह स्पष्ट करने के लिए अद्यतन किया गया है कि मैं मेवेन surefire – hertzsprung