how run cucumber with jenkins
यह ट्यूटोरियल ककड़ी जेनकींस एकता को स्पष्ट करने के लिए जेनकिंस और एक्सेल शीट के साथ ककड़ी का पूरा अवलोकन प्रदान करता है। :
इस ट्यूटोरियल में, हम जेनकिंस और एक्सेल शीट के साथ ककड़ी पर चर्चा करेंगे। हमें उम्मीद है कि यह ट्यूटोरियल आपके लिए उपयोगी होगा।
आप क्या सीखेंगे:
- जेनकिंस के साथ ककड़ी
- जेनकींस विन्यास
- ककड़ी जेनकींस रिपोर्ट
- ककड़ी एक्सेल
- अवलोकन
- निष्कर्ष
- अनुशंसित पाठ
जेनकिंस के साथ ककड़ी
टेस्ट स्क्रिप्ट स्वचालन
निम्नलिखित कॉन्फ़िगरेशन को करने की आवश्यकता है।
फ़ीचर फ़ाइल
फ़ीचर:
एक उपयोगकर्ता के रूप में
मैं सिस्टम में नए क्लाइंट जोड़ना चाहता हूं।
ताकि मैं उस ग्राहक के लिए लेखांकन डेटा जोड़ सकूं।
पृष्ठभूमि:
यह देखते हुए कि मैं जीथब होम पेज पर हूं।
जब मैं यूजरनेम 'xxxxxxxxxx' और पासवर्ड 'xxxxxxx' के रूप में निर्दिष्ट करता हूं।
और SignIn बटन पर क्लिक करें।
@ सोमोके
परिदृश्य: प्रोफ़ाइल का संपादन।
यह देखते हुए कि मैं आपके प्रोफाइल विकल्प पर क्लिक करता हूँ।
जब मैं एडिट प्रोफाइल बटन पर क्लिक करता हूँ।
और एक नई तस्वीर अपलोड की।
फिर मुझे नई प्रोफाइल पिक्चर देखनी चाहिए।
@Regression @Everytime
परिदृश्य: नई जिस्ट बनाएं।
यह देखते हुए मैं आपके जिस्ट विकल्प पर क्लिक करता हूं।
जब मैं फ़ाइल नाम, विवरण प्रदान करता हूं।
और Create public gist मेथड पर क्लिक करें।
तब मुझे नया जिन्न देखना चाहिए।
Stepdef फ़ाइल
fig_cropper.swf कैसे खोलें
package com.Multi; import cucumber.api.PendingException; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import cucumber.api.java.After; import cucumber.api.java.Before; import cucumber.api.java.en.But; import java.util.List; import cucumber.api.PendingException; import cucumber.api.java.it.Data; import cucumber.runtime.ScenarioImpl; import gherkin.formatter.model.Scenario; import gherkin.formatter.model.ScenarioOutline; import cucumber.api.DataTable; import org.junit.Assert; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import cucumber.api.cli.Main; public class Step2 { static public String sb; static public String sa; static WebDriver driver = null; @Before('@Smoke,@Regression') public void beforeScenario(){ System.out.println('New scenrio begins'); } @After('@Smoke,@Regression') public void afterScenario(){ System.out.println('Scenrio ends'); } @MyAnnotation public static void myanno() { System.out.println('my annot gets executed'); } @Given('^I am on Github home page$') public void i_am_on_Github_home_page(){ String site = 'https://www.github.com/login'; System.setProperty('webdriver.chrome.driver', 'Executables\chromedriver.exe'); driver = new ChromeDriver(); driver.navigate().to(site); //driver.findElement(By.cssSelector('a(contains(@href, 'login'))').click(); // Write code here that turns the phrase above into concrete actions } @When('^I specify Username as '((^')*)' and Password as '((^')*)'$') public void i_specify_Username_as_and_Password_as(String arg1, String arg2){ driver.findElement(By.cssSelector('input#login_field')).sendKeys(arg1); driver.findElement(By.cssSelector('input#password')).sendKeys(arg2); // Write code here that turns the phrase above into concrete actions } @When('^Click on SignIn button$') public void click_on_SignIn_button(){ driver.findElement(By.cssSelector('input.btn')).click(); // Write code here that turns the phrase above into concrete actions } @Given('^I click on Your Profile option$') public void i_click_on_Your_Profile_option(){ driver.findElement(By.xpath('//*(@id='user- links')/li(3)/details/summary/img')).click(); List olist = driver.findElements(By.xpath('//*(@id='user- links')/li(3)/details/ul/li/a(@class='dropdown-item')')); for(WebElement o:olist) { if(o.getText().equals('Your profile')) { o.click(); break; } } // Write code here that turns the phrase above into concrete actions } @When('^I click on edit profile button$') public void i_click_on_edit_profile_button(){ driver.findElement(By.xpath('//*(@id='js-pjax- container')/div/div(2)/div(1)/a')).click(); // Write code here that turns the phrase above into concrete actions } @When('^Uploaded new picture$') public void uploaded_new_picture() throws InterruptedException{ WebElement s1 = driver.findElement(By.xpath('//*(@class='avatar-upload- container clearfix')/Img')); sb=s1.getAttribute('src'); System.out.println(s1.getAttribute('src')); driver.findElement(By.id('upload-profile- picture')).sendKeys('D://cucumberFinal//multiple//Files//images.jpg'); Thread.sleep(10000); String wh = driver.getWindowHandle(); driver.switchTo().window(wh); Actions actions = new Actions(driver); WebElement element = driver.findElement(By.xpath('//div(@class='facebox -content')/form/div(3)/button')); Thread.sleep(10000); actions.moveToElement(element); //Thread.sleep(10000); actions.click(); //actions.sendKeys('GIST1 Description'); actions.build().perform(); // driver.findElement(By.xpath('//div(@class='facebox- content')/form/div(3)/button')).click(); Thread.sleep(3000); // Write code here that turns the phrase above into concrete actions } @Then('^I should be seeing new profile picture$') public void i_should_be_seeing_new_profile_picture(){ WebElement s1 = driver.findElement(By.xpath('//*(@class='avatar-upload- container clearfix')/Img')); sb=s1.getAttribute('src'); System.out.println(s1.getAttribute('src')); if(!(sb.equals(sa))) { Assert.assertTrue('File Upload successful', true); } // Write code here that turns the phrase above into concrete actions } @Given('^I click on Your Gists option$') public void i_click_on_Your_Gists_option(){ driver.findElement(By.xpath('//*(@id='user- links')/li(3)/details/summary/img')).click(); List olist = driver.findElements(By.xpath('//*(@id='user- links')/li(3)/details/ul/li/a(@class='dropdown-item')')); for(WebElement o:olist) { if(o.getText().equals('Your Gists')) { o.click(); break; } } // Write code here that turns the phrase above into concrete actions } @When('^I provide filename, description$') public void i_provide_filename_description() throws InterruptedException { // Write code here that turns the phrase above into concrete actions driver.findElement(By.xpath('//div(@class='edit container')/div(@id='gists')/input')).sendKeys('Gist1'); Thread.sleep(2000); Actions actions = new Actions(driver); WebElement element = driver.findElement(By.xpath('//*(@id='gists')/div(2)/div/div(2)/div/div(5)/div(1) /div/div/div/div(5)/div/pre/span')); actions.moveToElement(element); actions.click(); actions.sendKeys('GIST1 Description'); actions.build().perform(); // driver.findElement(By.xpath('//*(@id='gists')/div(2)/div/div(2)/div/div(5)/div(1) /div/div/div/div(5)/div/pre/span')).sendKeys('GIST1 Description'); Thread.sleep(2000); } @When('^click on Create public gist method$') public void click_on_Create_public_gist_method() { driver.findElement(By.xpath('//*(@id='new_gist')/div(2)/div(2)/button(1)')).click(); // Write code here that turns the phrase above into concrete actions } @Then('^i should be seeing the new gist$') public void i_should_be_seeing_the_new_gist(){ List glist = driver.findElements(By.xpath('//div(@class='container repohead-details -container')/ul(1)/li(@class='flex-auto')/div/a')); for(WebElement o:glist) { if(o.getText().equals('Gist1')) { System.out.println('Gist created successfully'); } } // Write code here that turns the phrase above into concrete actions } }
TestNG फ़ाइल
रनर फाइल
package runner; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import cucumber.api.testng.AbstractTestNGCucumberTests; import cucumber.api.SnippetType; @RunWith(Cucumber.class) @CucumberOptions( features='Features', glue='com.Multi', plugin={'html:target/cucumber-html-report', 'json:target/cucumber.json', 'pretty:target/cucumber-pretty.txt','usage:target/cucumber-usage.json', 'junit:target/cucumber-results.xml'}, dryRun = false, strict = true, tags={'@Smoke,@Regression'}, monochrome = true, snippets=SnippetType.CAMELCASE ) public class Runner extends AbstractTestNGCucumberTests{ }
जेनकींस विन्यास
पहुंच जेनकिंस यूआरएल ।
के लिए जाओ जेनकींस प्रबंधित करें> प्लगिन प्रबंधित करें ।
निम्नलिखित प्लगइन्स स्थापित करें:
- ककड़ी परीक्षण परिणाम प्लगइन
- ककड़ी की रिपोर्ट
- ककड़ी पूर्ण प्लगइन
सुनिश्चित करें कि सभी आश्रित प्लगइन्स को स्थापित करते समय सफलतापूर्वक स्थापित किया गया है अन्यथा रिपोर्टिंग प्लग इन काम नहीं कर सकते हैं।
अब नेविगेट करें प्रबंधित करें -> ग्लोबल टूल कॉन्फ़िगरेशन।
ठीक JDK के लिए रास्ता।
ठीक मावेन के लिए रास्ता।
बनाओ नई वस्तु मावेन परियोजना के रूप में।
एक बार नौकरी मिलने के बाद, बाएं हाथ के पैनल पर मौजूद कॉन्फ़िगर लिंक पर क्लिक करें।
नीचे स्क्रॉल करें पन्ना।
Pom.xml का पूर्ण पथ सेट करें, 'परीक्षण' के रूप में लक्ष्य करें और सहेजें विन्यास।
बाकी वेब सेवा साक्षात्कार प्रश्न और उत्तर
एक बार उपरोक्त चरण पूरा हो जाने पर, पर क्लिक करें अभी बनाएं वह लिंक जो मावेन प्रोजेक्ट के बाएं हाथ के पैनल में मौजूद है।
बिल्ड को निष्पादित और संबंधित किया जाएगा परीक्षण। xml फ़ाइल (जो pom.xml पर उल्लिखित है) निष्पादित हो जाएगा।
यहां वह आउटपुट है जो कंसोल पर प्रदर्शित होता है।
कंसोल आउटपुट
(जानकारी) टी ई एस टी एस
(जानकारी) ——————————————————————-
(जानकारी) रनिंग टेस्टसुइट
नया परिदृश्य शुरू होता है
ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) पोर्ट 27348 पर प्रारंभ करना
केवल स्थानीय कनेक्शन की अनुमति है।
log4j: WARN कोई लकड़हारा लकड़हारे के लिए नहीं मिला
(org.apache.http.client.protocol.RequestAddCookies)।
log4j: WARN कृपया log4j सिस्टम को ठीक से इनिशियलाइज़ करें।
log4j: WARN अधिक जानकारी के लिए http://log.apache.org/log4j/1.2/faq.html#noconfig देखें।
25 नवंबर, 2017 12:56:41 PM org.openqa.selenium.remote.ProtocolHandshake सृजन सत्र
जानकारी: पता लगाई गई बोली: ओ.एस.एस.
https://avatars3.githubusercontent.com/u/31874017?s=400&u=c41bfae0fa6b9325fb4f209885b51bd02c7d89d&v=4
https://avatars3.githubusercontent.com/u/31874017?s=400&u=c41bfae0fa6b9325fb4f209885b51bd02c7d89d&v=4
परिदृश्य समाप्त होता है
नया परिदृश्य शुरू होता है
ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) पोर्ट 24866 पर प्रारंभ करना
केवल स्थानीय कनेक्शन की अनुमति है।
25 नवंबर, 2017 12:57:45 PM org.openqa.selenium.remote.ProtocolHandshake सृजन सत्र
जानकारी: पता लगाई गई बोली: ओ.एस.एस.
परिदृश्य समाप्त होता है
2 परिदृश्य (2 पारित)
14 चरण (14 पारित)
2 एम .277
ओरेकल फॉर्म और रिपोर्ट साक्षात्कार प्रश्न
(जानकारी) टेस्ट चलते हैं: १, असफलताएँ: ०, त्रुटियां: ०, छोड़ दी गई: ०, समय समाप्त: १२aps.५१३ s - टेस्टसुइट में
(जानकारी)
(जानकारी) परिणाम:
(जानकारी)
(जानकारी) टेस्ट चलते हैं: 1, विफलताएं: 0, त्रुटियां: 0, छोड़ दिया: 0
(जानकारी)
(जेनकिंस) रिकॉर्डिंग परीक्षा परिणाम
(जानकारी) ——————————————————————————————
(जानकारी) निर्माण सफलता
(जानकारी) —————————————————————————————
(जानकारी) कुल समय: 02:51 मिनट
(जानकारी) २०१ at-११-२५ टीटी १२: ५ 45: ४५ + ०५: ३० पर समाप्त
(जानकारी) अंतिम मेमोरी: १२ एम / २O एम
(जानकारी) ——————————————————————————————
डेटा एकत्र करने के लिए जेनकींस का इंतजार करना
(जेनकिंस) संग्रह डी: cucumberFinal multiple pom.xml से com / cucumber.example / 0.0.1-SNAPSHOT / cucumber.example-0.0.1-SNAPSHOT.pom
चैनल बंद हो गया
समाप्त: सफलता
ककड़ी जेनकींस रिपोर्ट
ककड़ी एक्सेल
टेस्ट स्क्रिप्ट स्वचालन
निम्नलिखित कॉन्फ़िगरेशन को करने की आवश्यकता है।
टेस्ट डिजाइन रणनीति:
- एक एक्सेल रीडर उपयोगिता बनाएं, जिसमें एक्सेल शीट के ’कॉलमनाम’ को इनपुट पैरामीटर के रूप में लेने की क्षमता है और बदले में, यह एक्सेल शीट के val स्तंभकार ’को उस an स्तंभन’ के लिए देगा।
- एक फीचर फ़ाइल बनाएँ, जिसमें एक्सेल शीट का कॉलमनाम है, जो इसके किसी भी चरण में दोहरे उद्धरण चिह्नों में निर्दिष्ट है।
- अब सुविधा फ़ाइल के लिए एक संबंधित Stepdef फ़ाइल बनाएँ और पैरामीटर का उपयोग करें (arg1, arg2 etc..generated अगर हमने फीचर फ़ाइल पर दोहरे उद्धरण में शब्द निर्दिष्ट किया है) एक्सेल रीडर के लिए इनपुट के रूप में (चरण 1 में बनाया गया)।
- अब हमारे पास एक्सेल शीट का कॉलमवेल्यू है जिसका उपयोग Stepdef फाइल के इनपुट के रूप में किया जा सकता है।
- उपरोक्त चरण में बनाई गई सुविधा फ़ाइल को निष्पादित करें।
फ़ीचर फ़ाइल
फ़ीचर: अपनी सुविधा का शीर्षक
मैं अपनी सुविधा फ़ाइल के लिए इस टेम्पलेट का उपयोग करना चाहता हूं
पृष्ठभूमि:
यह देखते हुए कि मैं जीमेल पर हूं और स्क्रीन 'स्क्रीन' तक पहुंच रहा हूं।
यह देखते हुए कि मैं उपयोगकर्ता नाम को 'उपयोगकर्ता नाम' और पासवर्ड को 'पासवर्ड' के रूप में निर्दिष्ट करता हूं।
SignIn बटन पर क्लिक करें।
परिदृश्य: डेटा टेबल से नया संदेश बनाएं
जब मैं पॉपअप 'पॉपअप' को एक्सेस कर रहा हूं।
और मैं 'विषय' के रूप में निर्दिष्ट करता हूं और 'विषय' विवरण के रूप में और सबमिट बटन पर क्लिक करता हूं।
तब मुझे सफलता का संदेश देखना चाहिए।
एक्सेल फाइल
package com.cuexcel; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import com.google.common.collect.Maps; import gherkin.formatter.model.Row; public class Excel { private static String sheet = 'Sheet1'; private static String worksheet = 'D:\cucumberFinal\cuexcel\Files\tdata.xls'; static HashMap excelinfo = new HashMap(); public static String get(String ColName) throws IOException { FileInputStream fis; int k =0; String ColValue=null; fis = new FileInputStream(worksheet); HSSFWorkbook wb = new HSSFWorkbook(fis); HSSFSheet ws = wb.getSheet(sheet); int rows = ws.getPhysicalNumberOfRows(); HSSFRow HeaderRow = ws.getRow(0); for(Integer i=1;i Stepdef फ़ाइल
package com.cuexcel; import java.io.IOException; import java.util.ArrayList; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import cucumber.api.Scenario; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import cucumber.api.Scenario; import com.cuexcel.Excel; public class CExcel { static public WebDriver driver; Excel e; @Before public static void callexcel() throws IOException, InterruptedException { System.setProperty('webdriver.chrome.driver', 'Executables/chromedriver.exe'); driver= new ChromeDriver(); driver.manage().window().maximize(); driver.navigate().to('https://www.google.com/gmail/about'); } @Given('^I am on Gmail and accessing screen '((^')*)'$') public void i_am_on_Gmail_and_accessing_screen(String arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions driver.findElement(By.xpath('//nav/div/a(2)')).click(); //arg1=Excel.get().get(0).toString(); System.out.println(e.get(arg1) + ' - is clicked'); Thread.sleep(3000); } @Given('^I specify Username as '((^')*)' and Password as '((^')*)'$') public void i_specify_Username_as_and_Password_as(String arg1, String arg2) throws Throwable { //arg1=Excel.get().get(1).toString(); //arg2=Excel.get().get(2).toString(); driver.findElement(By.xpath('//input(@type='email')')).sendKeys(e.get(arg1). toString()); driver.findElement(By.xpath('//*(@id='identifierNext')/content/span')).click(); Thread.sleep(3000); driver.findElement(By.xpath('//input(@type='password')')). sendKeys (e.get(arg2). toString()); } @When('^Click on SignIn button$') public void click_on_SignIn_button() throws InterruptedException{ driver.findElement(By.xpath('//*(@id='passwordNext')/content/span')).click(); Thread.sleep(5000); } @When('^I am accessing the popup '((^')*)'$') public void i_am_accessing_the_popup(String arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions //arg1=Excel.get().get(3).toString(); driver.findElement(By.xpath('//*(@id=':x4')/div/div')).click(); System.out.println(e.get(arg1) + '- being clicked'); } @When('^I specify to as '((^')*)' and subject as '((^')*)' details and click on submit button$') public void i_specify_to_as_and_subject_as_details_and_click_on_submit_button(String arg1, String arg2) throws Throwable { // Write code here that turns the phrase above into concrete actions String whandle = driver.getWindowHandle(); driver.switchTo().window(whandle); //arg1=Excel.get().get(4).toString(); //arg2=Excel.get().get(5).toString(); driver.findElement(By.xpath('//td(@class='eV')/div(1)/div/textarea')).sendKeys (e.get(arg1)); driver.findElement(By.xpath('//table(@class='aoP aoC bvf')/tbody/tr/td/form/div(3)/input')).sendKeys(e.get(arg2)); driver.findElement(By.xpath('//table(@class='IZ')/tbody/tr/td/div')).click(); Thread.sleep(3000); } @Then('^i should be seeing the success message$') public void i_should_be_seeing_the_success_message() throws Throwable { // Write code here that turns the phrase above into concrete actions WebElement sent = driver.findElement(By.xpath('//*(@id='link_vsm')')); if(sent.isDisplayed()) { System.out.println('Message sent successfully'); } } }
POM फ़ाइल
4.0.0 com cuexcel 0.0.1-SNAPSHOT jar cuexcel http://maven.apache.org UTF-8 org.seleniumhq.selenium selenium-java 3.6.0 org.seleniumhq.selenium selenium-chrome-driver 3.6.0 info.cukes cucumber-core 1.2.5 info.cukes cucumber-java 1.2.5 test info.cukes cucumber-junit 1.2.5 test junit junit 4.11 test info.cukes cucumber-testng 1.2.0 info.cukes gherkin 2.12.2 provided log4j log4j 1.2.17 org.apache.poi poi-ooxml 3.9 org.apache.poi poi 3.11-beta3 xml-apis xml-apis 2.0.2 xerces xercesImpl 2.8.0 info.cukes cucumber-jvm-deps 1.0.5 provided net.masterthought cucumber-reporting 3.11.0 org.apache.maven.plugins maven-surefire-plugin 2.18 org.apache.maven.surefire surefire-junit47 2.18
एक बार उपरोक्त कॉन्फ़िगरेशन पूरा हो जाने के बाद, बस फीचर फाइल को निष्पादित करें।
अवलोकन
Stepdef फ़ाइल एक्सेल शीट से डेटा लेती है और फीचर फाइल में बताए गए परीक्षण चरणों को निष्पादित करती है।
यहाँ परीक्षा केस निष्पादन परिणाम है जैसा कि एक्लिप्स कंसोल पर बताया गया है।

निष्कर्ष
BDD टेस्ट ऑटोमेशन का भविष्य है क्योंकि यह सभी हितधारकों को टेस्ट स्क्रिप्ट निर्माण में भाग लेने में सक्षम बनाता है, विशेष रूप से फ़ीचर फ़ाइल पर उनके इनपुट प्रदान करने के लिए।
ककड़ी एक व्यापक रूप से इस्तेमाल किया जाने वाला बीडीडी उपकरण है और इसमें बहुत सारे एकीकरण और विशेषताएं हैं जिन्हें अभी तक परीक्षण स्वचालन में लागू किया जाना है। ककड़ी पर सक्रिय रूप से काम करने वाले कई समूह / समुदाय हैं।
अगर आप खीरे से अच्छी तरह वाकिफ हैं तो आप बाजार में उपलब्ध किसी भी बीडीडी टूल पर काम कर सकते हैं क्योंकि अधिकांश उपकरण ककड़ी के समान ही काम करते हैं।
हमें उम्मीद है कि आपने इस इन-ट्यूटोरियल ट्यूटोरियल के माध्यम से जेनकिंस के साथ ककड़ी के बारे में सीखा है।
अनुशंसित पाठ
- उदाहरणों के साथ पायथन डेटटाइम ट्यूटोरियल
- ककड़ी सेलेनियम ट्यूटोरियल: ककड़ी जावा सेलेनियम वेबड्राइवर एकीकरण
- उदाहरणों के साथ यूनिक्स शैल स्क्रिप्टिंग ट्यूटोरियल
- सेलेनियम उदाहरणों के साथ पाठ ट्यूटोरियल द्वारा तत्व का पता लगाएं
- जावा 'यह' कीवर्ड: कोड उदाहरणों के साथ ट्यूटोरियल
- बीडीडी और ककड़ी ट्यूटोरियल उदाहरण के साथ
- कोड उदाहरणों के साथ C # अपवाद हैंडलिंग ट्यूटोरियल
- ककड़ी उपकरण और सेलेनियम का उपयोग करके स्वचालन परीक्षण - सेलेनियम ट्यूटोरियल # 30