हाँ, यह filteringtestng.xml
परीक्षण संसाधन के द्वारा ही संभव है।
अपने पीओएम के अंदर, आपको अपनी गुण फ़ाइलों में एक फ़िल्टर पोटिंग घोषित करने की आवश्यकता है और संसाधन को फ़िल्टर करने के लिए <testResources>
को ओवरराइड करना होगा।
<build>
<filters>
<filter>path/to/test.properties</filter> <!-- relative to location of POM -->
</filters>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>testng.xml</include>
</includes>
<filtering>true</filtering>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<excludes>
<exclude>testng.xml</exclude>
</excludes>
</testResource>
</testResources>
<!-- rest of build section -->
</build>
आप गुण फ़ाइल एक महत्वपूर्ण test.browser
हो, तो यह सही ढंग से उस कुंजी के मान से plaholder ${test.browser}
की जगह लेगा। यह सब परीक्षण शुरू होने से पहले होगा, इसलिए टेस्टएनजी फ़िल्टर किए गए फ़ाइल को मूल्यों के साथ बदल देगा।
ध्यान दें कि ऊपर विन्यास केवल testng.xml
फिल्टर बहुत ज्यादा छानने से बचने के लिए। आप इसे एकाधिक फ़ाइलों को फ़िल्टर करने के लिए बढ़ा सकते हैं।
इसका मेरे लिए काम नहीं कर रहा। क्या आप कुछ और विवरण साझा कर सकते हैं, मैं application.properties फ़ाइल के लिए गुण पढ़ना चाहता हूं और इसे testng.xml पर फ़ीड करना चाहता हूं। –