2016-03-25 7 views
-1

私は、プラグインSauce on Demandを使用して、JuckinsでCucumberとSauceLabsを使用してテストを行っています。Jenkins Sauce On Demandを介してSauceLabsでジョブステータスを更新する

Sauce On Demandとの統合は、SauceLabsでPass/Failステータスを設定できないことを除いてうまくいきます。ログ

String message = String.format("SauceOnDemandSessionID=%1$s job-name=%2$s", 
      (((RemoteWebDriver) driver).getSessionId()).toString(), jobName); 
    System.out.println(message); 

キュウリランナークラスと設定

@RunWith(Cucumber.class) 
@CucumberOptions(
    glue = "abc", 
    features = "classpath:abc/Login.feature", 
    format = "junit:target/surefire-reports/Login.xml") 
public class LoginCucumberTest { 

} 
をログに

webdriverをインスタンス化

DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); 
    desiredCapabilities.setBrowserName(System.getenv("SELENIUM_BROWSER")); 
    desiredCapabilities.setVersion(System.getenv("SELENIUM_VERSION")); 
    desiredCapabilities.setCapability(CapabilityType.PLATFORM,System.getenv("SELENIUM_PLATFORM")); 

    desiredCapabilities.setCapability("build", System.getenv("JOB_NAME") + "_" + System.getenv("BUILD_NUMBER")); 
    desiredCapabilities.setCapability("name", jobName); 
    WebDriver driver = new RemoteWebDriver(
      new URL("http://"+System.getenv("SAUCE_USERNAME")+":"+System.getenv("SAUCE_ACCESS_KEY")+"@ondemand.saucelabs.com:80/wd/hub"), 
      desiredCapabilities); 

印刷セッションIDとのJobName

ジェンキンスはテストを示す構成

Jenkins configuration

ビルド結果がログ

Started by user Eduardo Marques 
 
Building in workspace /var/lib/jenkins/jobs/abc/workspace 
 
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10 
 
Fetching changes from the remote Git repository 
 
> /usr/bin/git config remote.origin.url ssh://[email protected]/automatizacao-abc.git # timeout=10 
 
Fetching upstream changes from ssh://[email protected]/automatizacao-abc.git 
 
> /usr/bin/git --version # timeout=10 
 
using GIT_SSH to set credentials Jenkins GIT key 
 
> /usr/bin/git -c core.askpass=true fetch --tags --progress ssh://[email protected]/automatizacao-abc.git +refs/heads/*:refs/remotes/origin/* 
 
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10 
 
> /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 
 
Checking out Revision 896524e677f23ff0696d9c0c9deb778e9ec76120 (refs/remotes/origin/master) 
 
> /usr/bin/git config core.sparsecheckout # timeout=10 
 
> /usr/bin/git checkout -f 896524e677f23ff0696d9c0c9deb778e9ec76120 
 
> /usr/bin/git rev-list e1225a75e40d7fc9ab47a3459d4c5e9ae3ee6a15 # timeout=10 
 
Starting pre-build for Sauce Labs plugin 
 
Starting Sauce Connect on master node using identifier: default 
 
Launching Sauce Connect on 172.30.0.123 
 
Sauce Connect 4.3.13 now launched for: eduardomarques 
 
Incremented process count for eduardomarques, now 1 
 
Finished pre-build for Sauce Labs plugin 
 
[workspace] $ /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven3.2.2/bin/mvn clean test 
 
[INFO] Scanning for projects... 
 
[INFO]                   
 
[INFO] ------------------------------------------------------------------------ 
 
[INFO] Building automatizacaoabc 1.0-SNAPSHOT 
 
[INFO] ------------------------------------------------------------------------ 
 
[INFO] 
 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ automatizacaoabc --- 
 
[INFO] Deleting /var/lib/jenkins/jobs/abc/workspace/target 
 
[INFO] 
 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ automatizacaoabc --- 
 
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 
 
[INFO] Copying 1 resource 
 
[INFO] 
 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ automatizacaoabc --- 
 
[INFO] Changes detected - recompiling the module! 
 
[INFO] Compiling 4 source files to /var/lib/jenkins/jobs/abc/workspace/target/classes 
 
[INFO] 
 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ automatizacaoabc --- 
 
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 
 
[INFO] Copying 1 resource 
 
[INFO] 
 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ automatizacaoabc --- 
 
[INFO] Changes detected - recompiling the module! 
 
[INFO] Compiling 3 source files to /var/lib/jenkins/jobs/abc/workspace/target/test-classes 
 
[INFO] /var/lib/jenkins/jobs/abc/workspace/src/test/java/abc/LoginTest.java: /var/lib/jenkins/jobs/abc/workspace/src/test/java/abc/LoginTest.java uses or overrides a deprecated API. 
 
[INFO] /var/lib/jenkins/jobs/abc/workspace/src/test/java/abc/LoginTest.java: Recompile with -Xlint:deprecation for details. 
 
[INFO] 
 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ automatizacaoabc --- 
 
[INFO] Surefire report directory: /var/lib/jenkins/jobs/abc/workspace/target/surefire-reports 
 

 
------------------------------------------------------- 
 
T E S T S 
 
------------------------------------------------------- 
 
Running abc.LoginCucumberTest 
 
SauceOnDemandSessionID=469a6e39f1cc4042885929c26e360340 job-name=Login com usuario valido 
 

 
1 Scenarios ([32m1 passed[0m) 
 
6 Steps ([32m6 passed[0m) 
 
0m15.918s 
 

 
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 16.894 sec 
 

 
Results : 
 

 
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0 
 

 
[INFO] ------------------------------------------------------------------------ 
 
[INFO] BUILD SUCCESS 
 
[INFO] ------------------------------------------------------------------------ 
 
[INFO] Total time: 21.163 s 
 
[INFO] Finished at: 2016-03-24T23:57:12+00:00 
 
[INFO] Final Memory: 17M/41M 
 
[INFO] ------------------------------------------------------------------------ 
 
Starting post-build for Sauce Labs plugin 
 
Shutting down Sauce Connect 
 
Decremented process count for eduardomarques, now 0 
 
Flushing Sauce Connect Input Stream 
 
Flushing Sauce Connect Error Stream 
 
Closing Sauce Connect process 
 
Sauce Connect stopped for: eduardomarques 
 
Finished post-build for Sauce Labs plugin 
 
Recording test results 
 
Starting Sauce Labs test publisher 
 
Finished Sauce Labs test publisher 
 
Finished: SUCCESS
0123を構築

Build result showing the test failed

を失敗しました

+0

それは明らか基づいていますあなたが提供した情報にあなたがまだ尋ねていない質問。 –

答えて

0

プラグインは、あなたの合否ステータスの更新を処理しません。私は、私のフレームワーク内でSauce-Restパッケージを使用して、Sauce Labs Pass/Failステータスを正常に更新できました。ここで

は、醤油、休憩レポへのリンクです:ここでは

https://github.com/saucelabs/saucerest-java

は私の作業コードです:

import com.saucelabs.saucerest.SauceREST; 

    public void UpdateResults(boolean testResults) throws JSONException, ClientProtocolException, IOException { 
     SauceREST saucerest = new SauceREST(USERNAME, ACCESS_KEY); 
     Map<String, Object> updates = new HashMap<String, Object>(); 
     updates.put("passed", testResults); 
     saucerest.updateJobInfo(sessionId, updates); 
    } 

    @After 
    public void tearDown() throws Throwable { 
     driver.quit(); 
     UpdateResults(testResults); 
     System.out.println("SauceOnDemandSessionID="+ sessionId + "job-name="+ jobName); 
    } 

出典:

https://github.com/saucelabs-sample-test-frameworks/Java-CucumberJVM/blob/master/src/test/java/com/yourcompany/saucecucumberjvm/GuineaPigSteps.java

関連する問題