• 占楼

  • 占楼

  • junit5引入参数化后会报异常,但不影响执行流程,报错信息如下,麻烦助教老师帮忙看看
    日志为删减版

     @Test
    @ParameterizedTest
    @MethodSource("phoneNumberAndVerifyProvider")
    void login(String phone,String verify){
    //void login(){
    accountPage=loginByPhonePage.login(phone,verify);
    assertThat(accountPage.getLoginResultContent(),equalTo("验证码错误"));
    }

    static Stream<Arguments> phoneNumberAndVerifyProvider() {
    return Stream.of(
    Arguments.of("13690881001", "1111"),
    Arguments.of("15690223459", "1234")

    );
    }

    org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.lang.String arg0] in method [void appium.test.TestLoginWithPhone.login(java.lang.String,java.lang.String)].

    at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:200)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:183)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:144)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:96)


    .org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)

    截图

  • 占楼

  • 作业
    -部门管理,增加、删除、上移、下移、修改
    -素材库,图片上传、图文上传

    https://github.com/xklf2014/seleniumdriver_java

  • 1楼

  • 1楼

    ##报告生产了,但是执行mvn命令报错了

    ##课后作业
    package org.openqa.selenium.firefox;
    import org.junit.Test;
    import org.junit.runner.RunWith;

    import static org.hamcrest.core.Is.is;
    import static org.junit.Assert.;
    import static org.mockito.ArgumentMatchers.any;
    import static org.mockito.ArgumentMatchers.isA;
    import static org.mockito.Mockito.
    ;
    import static org.hamcrest.Matchers.*;
    public class FirefoxProfileForTest {

    private String key = "testKey";
    private String defaultValue = "defult value";
    Preferences mockPreferences = mock(Preferences.class);

    @Test
    public void getStringPreferenceIsStringInstance() {
    when(mockPreferences.getPreference(any())).thenReturn("test I'm String instance");
    Object preference = mockPreferences.getPreference(key);
    assertThat(preference.getClass().getTypeName(),equalTo(String.class.getTypeName()));
    System.out.println("====================================================");
    System.out.println("function name : getStringPreferenceIsStringInstance");
    System.out.println("print object real type : 【" + preference.getClass().getTypeName()+"】");
    System.out.println("====================================================");
    }

    @Test
    public void getStringPreferenceIsNotStringInstance() {
    when(mockPreferences.getPreference(any())).thenReturn(new Thread());
    Object preference = mockPreferences.getPreference(key);
    System.out.println("====================================================");
    assertThat(preference.getClass().getTypeName(),not(equalTo(String.class.getTypeName())));
    System.out.println("function name : getStringPreferenceIsNotStringInstance");
    System.out.println("print object real type : 【" + preference.getClass().getTypeName()+"】");
    System.out.println("====================================================");
    }

    @Test
    public void getIntegerPreferenceIsIntegerInstance() {
    when(mockPreferences.getPreference(any())).thenReturn(666);
    Object preference = mockPreferences.getPreference(key);
    System.out.println("====================================================");
    assertThat(preference.getClass().getTypeName(),equalTo(Integer.class.getTypeName()));
    System.out.println("function name : getIntegerPreferenceIsNotIntegerInstance");
    System.out.println("print object real type : 【"+preference.getClass().getTypeName()+"】");
    System.out.println("====================================================");
    }

    @Test
    public void getIntegerPreferenceIsNotIntegerInstance() {
    when(mockPreferences.getPreference(any())).thenReturn("String type");
    Object preference = mockPreferences.getPreference(key);
    System.out.println("====================================================");
    assertThat(preference.getClass().getTypeName(),not(equalTo(Integer.class.getTypeName())));
    System.out.println("function name : getIntegerPreferenceIsNotIntegerInstance");
    System.out.println("print object real type : 【"+preference.getClass().getTypeName()+"】");
    System.out.println("====================================================");
    }

    @Test
    public void getBooleanPreference() {
    }

    @Test
    public void containsWebDriverExtension() {
    }
    }

    ##执行结果 (控制台输出)

    "D:\Program Files\JetBrains\IntelliJ IDEA 2019.2.1\jbr\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63781,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\Administrator.IntelliJIdea2019.2\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2019.2.1\lib\idea_rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2019.2.1\plugins\junit\lib\junit-rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA core-
    ......
    3.14.10.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 org.openqa.selenium.firefox.FirefoxProfileForTest
    Connected to the target VM, address: '127.0.0.1:63781', transport: 'socket'

    ====================================================
    function name : getIntegerPreferenceIsNotIntegerInstance

    print object real type : 【java.lang.String】

    ====================================================
    function name : getStringPreferenceIsNotStringInstance

    print object real type : 【java.lang.Thread】

    ====================================================
    function name : getStringPreferenceIsStringInstance

    print object real type : 【java.lang.String】

    ====================================================
    function name : getIntegerPreferenceIsNotIntegerInstance

    print object real type : 【java.lang.Integer】

    Disconnected from the target VM, address: '127.0.0.1:63781', transport: 'socket'

    Process finished with exit code 0

  • #javaagent启动jmeter

    #生成无源码的html报告

    #生产关联源码的html报告

  • 占楼