小编Mus*_*eas的帖子

即使前一个类失败,TestNG也会继续执行测试类

如果一个TestCase(Class)失败,为什么TestNG会继续执行测试?

例如,testoutput是:

1 test passed, 1 test failed.(3599,0 s)
    TestSuite FAILED
        run FAILED: check5=3 Expected: <3> got: <5>
        run passed (1.0s)    // <--- this should not have been executed
Run Code Online (Sandbox Code Playgroud)

为什么第二次运行甚至被执行?我的testngsuite.xml:

<suite name="TestSuite_03">
    <test name="TestCase_17">
        <groups>
            <run><include name="functest"/></run>
        </groups>
        <classes>
            <class name="TestStep_003" desc="will fail" />
            <class name="TestStep_012" desc="will pass" />
        </classes> ...
Run Code Online (Sandbox Code Playgroud)

我通过NetBeans使用Maven,TestNG和Java

我的结构:

public abstract class TestCommon
{
    @BeforeSuite(groups={"functest})
    public void BeforeSuite()
    {
        // clean report folder
    }
    @BeforeTest(groups={"functest})
    public void BeforeTest()
    {
        // start selenium browser
    }
    @AfterMethod(groups={"functest})
    public …
Run Code Online (Sandbox Code Playgroud)

java testng selenium maven

5
推荐指数
1
解决办法
7556
查看次数

TestNG retryAnalyzer 仅在方法 @Test 中定义时才起作用,在类的 @Test 中不起作用

这按预期工作,测试失败(由于haltTesting())并重复2x

public class A0001_A0003Test extends TestControl {

    private Kunde kunde = Kunde.FR_WEHLITZ;

    @Test(retryAnalyzer = TestRepeat.class, groups = {TestGroups.FAILED}, description = "verify adress")
    public void testkundenDaten_Angaben() throws Exception {
        bifiTestInitial();
        testActions.selectKunde(kunde);
        haltTesting();
    }
} 
Run Code Online (Sandbox Code Playgroud)

但因为我在一个类中有多个测试,所以我在类级别定义了重复分析器

@Test(retryAnalyzer = TestRepeat.class)
public class A0001_A0003Test extends TestControl {

    private Kunde kunde = Kunde.FR_WEHLITZ;

    @Test(groups = {TestGroups.FAILED}, description = "verify adress")
    public void testkundenDaten_Angaben() throws Exception {
        bifiTestInitial();
        testActions.selectKunde(kunde);
        haltTesting();
    }
} 
Run Code Online (Sandbox Code Playgroud)

但随后测试不再重复,文档说:

类级别@Test注解的作用是使该类的所有公共方法即使没有注解也成为测试方法。如果您想添加某些属性,您仍然可以在方法上重复 @Test 注释。

所以这应该是可能的,还是我期待错误的结果?

java testng selenium automated-tests repeat

5
推荐指数
1
解决办法
7797
查看次数

无法使用 Java 客户端使用 Appium 滚动 Android 应用程序

我无法使用 Appium 向下滚动到 Android 应用程序中任何页面的底部。尝试了多种方法,包括在 Stack Overflow 上找到的方法。(这个挑战似乎很常见。)然而,所有的尝试都失败了。

环境:

  • Appium 版本:1.6.2
  • Appium 客户端:Java (java-client-6.1.0.jar)
  • 安卓版本:5.1、6.0.1、7.1.1
  • Java版本:jre1.8.0_171
  • 硒版本:selenium-java-3.13.0
  • 应用类型:Cordova(混合);该应用程序是用 Cordova 构建的,但在运行时System.out.println(driver.getContext());,结果是NATIVE_APP

请分享可以解决此问题的任何替代方案或改进。非常感谢任何有用的建议!

以下总结了尝试的各种方法:

  1. 方法:scrollIntoView()(各种实现)
  2. driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"send-to-email-app\"));").click();
  • 来源:Udemy 课程
  • 错误:不滚动且没有错误

  • 方法:尝试 catch > scrollIntoView()
  • try { driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"Send\"))"); }catch(Exception e) { System.out.println("We got an error scrolling!"); }
    • 来源:/sf/ask/2776103851/
    • 错误:部分有效:页面向下滚动但不够远

  • 方法:滑动
  • driver.swipe(0, Startpoint,0,scrollEnd,1000);
    • 来源:/sf/ask/2739141401/
    • 错误:不推荐使用滑动

  • 方法:touchAction.longPress + moveTo
  • ...touchAction.longPress(fromX, fromY).moveTo(toX, toY).release().perform();
    • 来源:/sf/ask/3099769221/
    • 错误:“无法解析驱动程序”

  • 方法:touchAction.longPress + moveTo
  • TouchAction touchAction = new TouchAction(driver); touchAction.longPress(10, 10).moveTo(x, y).release().perform();
    • 来源:/sf/ask/3099769221/
    • 错误:“TouchAction 类型中的 longPress(LongPressOptions) …

    java android scroll scrollview appium

    5
    推荐指数
    1
    解决办法
    5990
    查看次数

    NetBeans:使用-e开关重新运行Maven/PluginResolutionException

    我对Maven和Netbeans一无所知,我更新了我的netbeans,现在我的测试不再适用了:

    Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed    to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact    org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo1.maven.org/maven2): pr-dfs-bank-   00.emea.isn.corpintra.net: Unknown host pr-dfs-bank-00.emea.isn.corpintra.net -> [Help 1]
    
    To see the full stack trace of the errors, re-run Maven with the -e switch.
    Re-run Maven using the -X switch to enable full debug logging.
    
    For more information about the errors and possible solutions, please read the following articles:
    [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
    
    Run Code Online (Sandbox Code Playgroud)

    如何使用netbeans激活-e或-X开关,我看到很多带有"mvn clean"等的例子,但我通过Netbeans安装了Maven,所以我没有在命令行的文件夹上.我没有收到错误消息,想要查看更详细的日志. …

    selenium maven-2 netbeans exception pom.xml

    4
    推荐指数
    3
    解决办法
    2万
    查看次数

    Maven无法从具有多个接口的类中加载JUnit类别的组?

    我的Maven:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.15</version>
                    <configuration>
                        <groups>
                            com.rubberduck.TestState.Ready
                        </groups>
                    </configuration>
                </plugin>
    
    Run Code Online (Sandbox Code Playgroud)

    我的课:

    package com.rubberduck;
    public class TestState
    {
        public interface Ready {
            /* to allow filter ready tests as groups */
        }    
        public interface InProgress {
            /* to allow filter ready tests as groups */
        }    
        public interface NotTested {
            /* to allow filter ready tests as groups */
        }    
    }
    
    Run Code Online (Sandbox Code Playgroud)

    我的测试:

    @Test(timeout = 60000)
    @Category(TestState.Ready.class)
    public void test() throws Exception {
        assertEquals(true, true);
    }
    
    Run Code Online (Sandbox Code Playgroud)

    我的错误:

    Failed to execute goal …
    Run Code Online (Sandbox Code Playgroud)

    junit interface categories maven

    4
    推荐指数
    1
    解决办法
    2765
    查看次数

    Java DecimalFormat显示float和double的不同结果

    为什么结果不同?如果我使用浮动它得到,675如果我使用双我得到,674 ...不是很奇怪?

    float f = 12345.6745;
    double d = 12345.6745;
    
    Locale l = Locale.forLanguageTag("es-ES");
    DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(l);
    print(df.format(f));
    >> 12.345,675
    
    l = Locale.forLanguageTag("es-ES");
    DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(l);
    print(df.format(d));
    >> 12.345,674
    
    Run Code Online (Sandbox Code Playgroud)

    谢谢

    java floating-point double decimalformat

    0
    推荐指数
    1
    解决办法
    1064
    查看次数

    如何从另一个项目和包中访问.java文件?

    我有两个项目

    D:\Project_A\src...
    D:\Project_B\src...
    
    Run Code Online (Sandbox Code Playgroud)

    现在我想通过Project_A从Project_B访问Java文件.

    如果解决方案不涉及IDE中的任何点击,我将不胜感激,因为它应该是独立于IDE的.

    即:

    package Project_A
    import Project_B.src.test.meow.wuff.MyClass
    
    MyClass x = new MyClass();
    
    Run Code Online (Sandbox Code Playgroud)

    java import package

    -7
    推荐指数
    1
    解决办法
    2013
    查看次数