简体   繁体   English

可以找到类名,但不能在Jmeter中找到测试方法

[英]Can find class name, but can't find Test Method in Jmeter

I am trying to integrate jmeter with selenium. 我正在尝试将jmeter与硒集成。 I wrote a script, exported it as jar, saved it in lib/junit. 我编写了一个脚本,将其导出为jar,并将其保存在lib / junit中。 Then added a Junit request sampler to my thread. 然后将Junit请求采样器添加到我的线程中。 I can find the relevant class name, but the Test Method list is empty. 我可以找到相关的类名,但是“测试方法”列表为空。 Here is the code: 这是代码:

import java.util.concurrent.TimeUnit;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.junit.Test;


public class SeleniumTest extends TestCase{

    WebDriver driver=null;
@Before
public void setUp()  {
    driver=new FirefoxDriver();

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
    public void login()
    {

       driver.get("http://www.website.com/");
       try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
       driver.findElement(By.id("inputEmail")).clear();
       driver.findElement(By.id("inputEmail")).sendKeys("username");
       driver.findElement(By.id("inputPassword")).clear();
       driver.findElement(By.id("inputPassword")).sendKeys("password");
       driver.findElement(By.cssSelector("div.controls > button.btn")).click();
    }

@After
public void tearDown()  {
    driver.quit();
}

}

I think that you need to change your method name to start with test , ie to testLogin 我认为您需要更改方法名称以test开头,即testLogin

Also by default JMeter's JUnit Request Sampler is looking for JUnit3-style test cases naming. 同样,默认情况下,JMeter的JUnit Request Sampler也在寻找JUnit3样式的测试用例命名。 Looking into your code I see that you're using JUni4 annotations so you need to check "Search for JUnit4 annotations" box. 查看代码,我发现您正在使用JUni4批注,因此需要选中“搜索JUnit4批注”框。

For more details on JUnit Request Sampler you can refer to How to Use JUnit With JMeter guide. 有关JUnit Request Sampler的更多详细信息,请参阅如何将JUnit与JMeter一起使用指南。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM