Jenkins错误:包javax.mail不存在,请导入javax.mail.Message;

时间:2018-10-10 13:59:28

标签: java eclipse email jenkins gradle

在我的代码中,我正在使用Appium和SeeTest.Io运行一些测试。 当我从Eclipse运行代码时,它可以正常工作,并在测试后发送电子邮件。

package apptest;


import java.net.URL;
import java.util.Properties;

import javax.mail.MessagingException;
import javax.mail.internet.AddressException;

import org.openqa.selenium.By;

import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import com.experitest.appium.SeeTestClient;


import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;



public class WP_Login extends BaseTest implements GlobalConstants { 
    protected AndroidDriver<AndroidElement> driver = null;
    protected SeeTestClient client;
    protected String ReportURL = System.getenv("ReportURL");
    protected String TestName = System.getenv("testName");

@BeforeMethod
@Parameters("deviceQuery")
public void setUp(@Optional("@os='android'") String deviceQuery) throws Exception{
    init(deviceQuery);
    // Init application / device capabilities
    /*dc.setCapability(MobileCapabilityType.APP, "cloud:com.consul.android.smartbeer.staging/com.whirlpool.ted.View.SplashActivity");
    dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.consul.android.smartbeer.staging");
    dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.whirlpool.ted.View.SplashActivity");*/
    dc.setCapability("testName", "wp_TED_Login");
    dc.setCapability("deviceQuery",S8+"or"+S7+"or"+S6Edge+"or"+S7Edge);
    //dc.setCapability("deviceQuery",androidnuvem);
    driver = new AndroidDriver<>(new URL(getProperty("url",cloudProperties) +"/wd/hub"), dc);
    client = new SeeTestClient(driver);

}

@Test
 public void testeLogin() {
      driver.installApp("cloud:com.consul.smartbeer/com.whirlpool.ted.View.SplashActivity");
      client.launch("com.consul.smartbeer/com.whirlpool.ted.View.SplashActivity", false, true);
      try{Thread.sleep(esperandogifinicial);} catch(Exception ignore){}
      driver.findElement(By.xpath("//*[@text='Acesse sua conta']")).click();
      driver.findElement(By.xpath("//*[@id='edEmail']")).sendKeys("tedmonitoramento@gmail.com");
      driver.findElement(By.xpath("//*[@id='edPassword']")).sendKeys("Smart2000");
      driver.findElement(By.xpath("//*[@text='Entrar']")).click();
}

/*@Test
 public void testeLoginQA() {
  driver.installApp("cloud:com.consul.android.smartbeer.staging/com.whirlpool.ted.View.SplashActivity");
  client.launch("com.consul.android.smartbeer.staging/com.whirlpool.ted.View.SplashActivity", false, true);
  try{Thread.sleep(esperandogifinicial);} catch(Exception ignore){}
  driver.findElement(By.xpath("//*[@text='Acesse sua conta']")).click();
  driver.findElement(By.xpath("//*[@id='edEmail']")).sendKeys("tedmonitoramento@gmail.com");
  driver.findElement(By.xpath("//*[@id='edPassword']")).sendKeys("Smart2000");
  driver.findElement(By.xpath("//*[@text='Entrar']")).click();
  try{Thread.sleep(esperandogifinicial+2500);} catch(Exception ignore){}
  driver.findElement(By.xpath("//*[@id='imgCart']")).click();
}*/

@AfterMethod
public void tearDown(ITestResult tr) throws AddressException, MessagingException{
    driver.removeApp("com.consul.android.smartbeer.staging");
    ReportURL = driver.getCapabilities().getCapability("reportUrl").toString();
    TestName = "wp_TED_Login";
    if (driver!=null)
    {
        Email e = new Email();
        e.setMailServerProperties();
        e.createEmailMessage(ReportURL, TestName);
        e.sendEmail();
        if (tr.isSuccess()) 
        {
            client.report("Test has passed", true);

        }
        else {
            client.report("Test has failed", false);
        }
        System.out.println("report URL : " + driver.getCapabilities().getCapability("reportUrl"));
        //System.getenv(driver.getCapabilities().getCapability("reportUrl"));
        System.setProperty(ReportURL, driver.getCapabilities().getCapability("reportUrl").toString());
        driver.quit();
    }
}

}

但是当我尝试使用Jenkins运行相同的代码时,测试失败并带来了这个结果

  

卢旺斯·卢卡斯·莫雷拉·多斯·桑托斯建筑事务所   工作区C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login

     
    

git.exe rev-parse --is-inside-work-tree#timeout = 10从远程Git存储库获取更改     git.exe config remote.origin.url https://lar-whirlpool@bitbucket.org/whirlpooldigital/automated-testing.git

         

timeout = 10从https://lar-whirlpool@bitbucket.org/whirlpooldigital/automated-testing.git提取上游更改

         

git.exe --version#timeout = 10,使用GIT_ASKPASS设置凭据     git.exe提取--tags --progress https://lar-whirlpool@bitbucket.org/whirlpooldigital/automated-testing.git     + refs / heads / :refs / remotes / origin /     git.exe rev-parse“ refs / remotes / origin / master ^ {commit}”#超时= 10     git.exe rev-parse“ refs / remotes / origin / origin / master ^ {commit}”#timeout = 10检出修订版     29b14ff325d23e5efb59ed6a24c45b41422e6fa4(引用/远程处理/来源/母版)     git.exe配置core.sparsecheckout#timeout = 10     git.exe签出-f 29b14ff325d23e5efb59ed6a24c45b41422e6fa4提交消息:“ teste”     git.exe rev-list --no-walk 2cef3325f58cc91f607bccc2aa930d54c46313f4#timeout = 10 [Gradle]-启动构建。 [TED_登录] $ cmd.exe / C'“” C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ gradlew.bat“'     test --tests apptest.WP_Login.testeLogin && exit %% ERRORLEVEL %%“     启动Gradle守护程序,可能有1个不兼容的守护程序和3个已停止的守护程序     不可重用,请使用--status获取详细信息:compileJava NO-SOURCE     :processResources NO-SOURCE:类别为最新     :compileTestJavaC:\ Program文件     (x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:5:     错误:程序包javax.mail不存在import javax.mail.Message;                      ^ C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:6:     错误:程序包javax.mail不存在导入     javax.mail.MessagingException;                      ^ C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:7:     错误:包javax.mail不存在import javax.mail.Session;                      ^ C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:8:     错误:包javax.mail不存在import javax.mail.Transport;                      ^ C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:9:     错误:包javax.mail.internet不存在导入     javax.mail.internet.AddressException;                               ^ C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:10:     错误:包javax.mail.internet不存在导入     javax.mail.internet.InternetAddress;                               ^ C:\ Program Files(x86)\ Jenkins \ workspace \ TED_Login \ src \ test \ java \ apptest \ Email.java:11:     错误:包javax.mail.internet不存在导入     javax.mail.internet.MimeMessage;     失败

  
     

失败:构建失败,并出现异常。

     
      
  • 出了什么问题:任务':compileTestJava'的执行失败。

         
        

    编译失败;有关详细信息,请参见编译器错误输出。

      
  •   
  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获取完整的见解。

  •   
  • https://help.gradle.org

  • 获得更多帮助   
     

在19年代失败,完成1项可执行的任务:1项执行Build step'Invoke   Gradle脚本'将生成结果更改为FAILURE Build步骤'Invoke   Gradle脚本将构建标记为失败完成:FAILURE

我的疑问是:我应该在Eclipse内部的build.gradle中编辑任何内容,还是有什么方法可以将此JAR导入Jenkins? 因为在Eclipse上效果很好

这是我的文件build.gradle

group 'com.experitest'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url "https://cloud.experitest.com/repo" }
    maven { url "http://repo.experitest.com:8010/Maven2/"}

    mavenCentral()
}


dependencies {
    compile(group: 'com.experitest', name: 'seetest-appium', version: '10.8')
    compile 'com.experitest:manager-client:1.6'
    compile group: 'org.testng', name: 'testng', version: '6.9.10'
    compile 'org.hamcrest:hamcrest-library:1.3'
    compile 'com.experitest:repo:1.1'
    compile 'com.experitest:appium-seetest-extension:11.4'
}

test {
    useTestNG()
}

0 个答案:

没有答案