我有一个带有TestNG的maven项目。我以前使用Eclipse,今天搬到了IntelliJ,我认为我配置正确。但是当我在IntelliJ中运行这个项目时,它不能在下面的错误信息下运行。当使用maven命令mvn test
运行时,它没有任何问题。
但是当我从IntelliJ跑过来时,我得到:
@w@C:\用户\sdymj\AppData\本地\Temp\idea_working_dirs_testng.tmp-temp C:\用户\sdymj\AppData\本地\Temp\idea_testng.tmp[TestNG]运行: D:\Work\SW Engineering\WFC-Test\testng.xml
java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:250)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:227)
at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:55)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:72)
at com.samsung.wfctest.TestStart.setUp(TestStart.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:217)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:144)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
----密码----
@BeforeSuite (alwaysRun = true)
public void setUp() throws Exception {
// DesiredCapability delivers all the necessary info to Appium server
// so that Appium server can handshake with the device and handle it properly
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "DUT");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, Util.WAIT_TIME);
cap.setCapability("appPackage", Util.TARGET_PACKAGE); //
cap.setCapability("appActivity", Util.TARGET_ACTIVITY);
// below codes are only for N OS - works find without these in M OS
Process process = Runtime.getRuntime().exec("adb uninstall io.appium.settings");
process.waitFor();
process = Runtime.getRuntime().exec("adb uninstall io.appium.unlock");
process.waitFor();
// create Appium server session
driver = new AndroidDriver(new URL(Util.APPIUM_URL), cap);
util = new Util();
}
--------导入类----------
package com.samsung.wfc;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.apache.log4j.Logger;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.URL;
import java.util.List;
----------- pom.xml --------------
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.samsung</groupId>
<artifactId>WFCTest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>5.0.0-BETA1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-api -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>2.19.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.6.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>wfctest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
--------- testng.xml -----------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<classes>
<class name="com.samsung.wfc.TestStart"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
这就是原因。。它被设置为“AndroidAPI”,我改为第一个选项“1.8”,不知怎的,它成功了。
我已经用maven和testNG配置了eclipse,用我的pom配置了PF。xml如下: 我是runnong,在命令提示符下点击这个目录:D:\EclipseWorkspace\iON27Feb2013\iONAutomation\common 我的cmd控制台显示:
我有一个用TestNG运行的简单代码,但是我不能用Gradle运行,因为它说没有找到主方法,这并不奇怪,因为我使用注释。 但在这种情况下,如果必须使用Gradle,如何运行代码。 请注意,我对Gradle很陌生,对这方面的知识不多。 代码: 上面的代码与TestNG库完美运行。然而不是格拉德尔。 以下是我的Gradle构建设置: Gradle返回没有Main方法。 谢谢你的帮助。
1.我从“git克隆https://github.com/corda/samples"”下载的 2.我从Intellij As页面打开项目(https://docs.corda.net/tutorial-cordapp.html#downloading-示例cordapp)显示 3.我选择了“运行示例CordApp-静态编程语言”,并开始调试 4.我从智能控制台得到一些例外 我访问“网址”,但它不
这是我的pom.xml文件,它既不能在VS代码中运行应用程序,也不能在Eclipse中运行应用程序,每次运行项目时,它都会给出构建错误“failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.1.release:run”这是我的错误屏幕截图 我在https://start.spring.io上创建了我
主要内容:创建临时配置,创建永久配置,创建新配置,共享配置IntelliJ IDEA 有很多方法可以为正在运行的项目创建配置。配置选项是: 创建临时配置 创建永久配置 在用户之间共享配置 创建临时配置 创建项目 创建Java 类 右键单击并选择运行选项 在运行菜单上添加了临时配置。 创建永久配置 当我们使用 Intellij Idea保存临时配置时,它可以转换为永久配置。要保存此配置,请单击“Run”菜单上的“Save Configuration”。我们
我正在尝试使用TestNG来测试我的Java代码。TestNG插件安装在IntelliJ中,依赖项: 已添加到Maven中。然而,当我在类中写入“@Test”时,IntelliJ给出了错误消息:“无法解析符号'Test'。 导入组织。testng。注释。测试也无法识别。Intellij似乎忽略了Maven依赖。 以下是项目结构和错误: 我应该用TestNG做更多的事情,而不是仅仅添加Maven依赖