Tag: testng

如何使用testng标签进行烟雾回归测试

我有几种测试方法,我需要选择其中一些作为烟雾测试和其他回归测试。 我如何在Testng selenium中创建条件/依赖,因此烟雾测试将首先作为一组运行。 我可以为回归测试设置不同的Bamboo作业,只有在测试组通过后才能运行。 这是我的测试是: @Test(priority=1) public void test_1(){ —-} @Test(priority=2) public void test_2(){ —-} @Test(priority=3) public void test_3(){ —-} @Test(priority=4) public void test_4(){ —-} @Test(priority=5) public void test_5(){ —-} 这里,test_1到test_3是烟雾测试。 所以,如果他们通过其他人将被执行。 我怎样才能做到这一点?

测试通过但行动没有发生selenium webdriver + testng

我是selenium webdriver的新手,我在IE 8上使用2.31版本,testng 6.8和防火测试。我在这个方案中编写我的测试:我有测试类,我有使用testng @Test注释的方法。 它看起来像这样: @Test(description=”click Save Button “, dependsOnMethods = { “edit form” }) public void clickSaveButton(ITestContext context) { page.clickSaveButton(driver); } 然后,正如你所看到的,我有一个页面类,我存储元素id,xpath等。它像这样lokks: public void clickSaveButton(WebDriver driver){ Configuration.clickfoundElement(By.id(conf.get(“saveButton”)), driver); } conf是表示属性文件的对象。 最后我有Configuration类,我在这里做了一些思考: public static void clickfoundElement(By by, WebDriver driver){ int attempts = 0; while(attempts < 10) { try { driver.findElement(by).click(); break; } catch(NoSuchElementException e) […]

如何在TestNg类之间传递WebDriver的单个实例

我无法在网上的任何地方找到一个不同的答案。 我有多个TestNg类来运行测试,BrowserFunctions,登录,搜索,过滤(测试亚马逊的实践)。 我还有一个BrowserLauncher类,它根据浏览器名称和testng.xml文件返回相应的webdriver。 BrowserFunctions.java public class BrowserFunctions { BrowserLauncher bl = new BrowserLauncher(); WebDriver driver; StringBuilder sb = new StringBuilder(); @BeforeSuite public void initialioseBrowser() { driver = bl.launchBrowser(“Firefox”); } @Parameters({ “URL” }) @BeforeSuite public void invokeURL(String URL) { driver.get(URL); } @AfterSuite public void closeBrowser() { driver.close(); } Login.java public class Login { BrowserLauncher bl = […]

Maven / Surefire没有找到unit testing

我尝试用maven创建一个测试项目,unit testing工作正常。 但是,当尝试为j2ee项目执行相同操作时,无法通过surefire找到unit testing。 测试位于正确的目录(src / test / java)中,并且正在编译它们。 junit测试位于src / test / java / unit / TestAddition.java pom.xml中的surefire插件配置不包含/排除任何文件。 org.apache.maven.plugins maven-surefire-plugin 2.8 和junit,testng junit junit 4.8.2 test org.testng testng 6.0.1 test 这是“ mvn clean test ”的输出 [DEBUG] (s) reportFormat = brief [DEBUG] (s) reportsDirectory = c:\workspace\JAdaptivLatest\target\surefire-reports [DEBUG] (s) runOrder = filesystem [DEBUG] (s) session = […]

unit testing框架 – 使用可配置值定义threadPoolSize的TestNG

我正在挖掘一下TestNG框架。 我在我的测试用例中使用注释来配置线程值,例如: @Test(threadPoolSize = 2, invocationCount = 10) public void testOne() { //some code } 这个想法是在配置文件中配置这些值,这些值应该传递给所有测试。 所以我需要从配置项中更改这些值或通过unitTest构造函数传递此值,但TestNG只接受CONSTANT值。 任何提示/想法? 提前致谢!

如何从csv文件中将参数传递给testng中的数据提供者

我从csv文件读取数据,我测试了这个数据将作为输入。 我希望它作为每组价值的测试用例运行。 因为我正在使用数据提供程序问题是,它只占用最后设置的数据行,请帮我调试代码 For eg : if my csv has following data name1 id1 text1 name2 id2 text2 name3 id3 text3 它只取最后一行name3 id3 text3并且只运行一次测试一次不是三次。 @DataProvider(name = “test”) public Object[][] provider( ) throws InterruptedException { Object[][] returnObject ; String[] checkpoint = ReadfromCSV(); count = count + 1; returnObject = new Object[][]{checkpoint }; return returnObject; } @Test(description […]

LazyInitializationException,同时使用TestNG对Spring中使用的Hibernate实体类进行unit testing

在我的Spring配置中,我已经要求会话在我的视图中保持打开状态: 但是,这个bean似乎并不认为我的TestNGunit testing是一种观点。 ;-)那没关系,但是unit testing是否有类似的bean,以便在unit testing时避免可怕的LazyInitializationException? 到目前为止,我的一半unit testing因此而死亡。 我的unit testing通常如下所示: @ContextConfiguration({“/applicationContext.xml”, “/applicationContext-test.xml”}) public class EntityUnitTest extends AbstractTransactionalTestNGSpringContextTests { @BeforeClass protected void setUp() throws Exception { mockEntity = myEntityService.read(1); } /* tests */ @Test public void LazyOneToManySet() { Set entities = mockEntity.getSomeEntitySet(); Assert.assertTrue(entities.size() > 0); // This generates a LazyInitializationException } } 我已经尝试将setUp()更改为: private SessionFactory sessionFactory […]

在TestNG中运行多个类

我正在尝试自动化一个场景,其中,我想一次登录到应用程序然后进行操作而无需再次重新登录。 考虑一下,我有代码在特定类的@BeforeSuite方法中登录应用程序。 public class TestNGClass1 { public static WebDriver driver; @BeforeSuite public static void setUp(){ System.setProperty(“webdriver.chrome.driver”, “D://Softwares//chromedriver.exe”); driver = new ChromeDriver(); //driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get(“https://www.myfitnesspal.com”); } @AfterSuite public static void close(){ driver.close(); } } 我在TestNGClass2中有@test方法,它基本上试图点击一些登录按钮。 public class TestNGClass2 extends TestNGClass1 { public static WebDriver driver; @Test public static void login(){ System.out.println(“Entering the searchQuery […]

以编程方式运行TestNG需要循环来自动创建多个测试

我想知道是否有人可以给我正确的方向。 不确定我是否正确使用Map或HashMap进行循环。 我知道如果我做一个参数但是我喜欢在以编程方式创建XML时执行1-100个主机参数。 你能告诉我创建循环需要做什么,这样我就可以用主机值为1-100的参数创建多个测试。 我的代码如下: package firsttestngpackage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.TestNG; import org.testng.xml.XmlClass; import org.testng.xml.XmlSuite; import org.testng.xml.XmlTest; public class Test1 { WebDriver driver; WebDriverWait wait; private void testRunner(Map testngParams) { TestNG testNG = new TestNG(); XmlSuite suite = getXmlSuite(); XmlTest test = getXmlTest(suite); test.setParameters(testngParams); List […]

TFS和TestNG – 可以在TFS2015内执行TestNG测试吗?

TFS和TestNG – 可以在TFS2015内执行TestNG测试吗? 我已经在我的TFS实例中将一个Java Maven项目上传到了Repo。 我的java Maven项目包含TestNG Test / classes 我可以看到TFS中有一个Maven插件,它也有一个JUnit链接。 4.我无法看到任何让我在TFS中执行TestNG测试的选项,是否可能?