Я использую TestNG для своего проекта Maven, используя данные из файла .xlsx для тестовых случаев. Хотя эти данные правильно выводятся в консоли, TestNG не правильно читает определенные символы (от é до Ã, Î до Ã, ç до ç§).
Я пробовал почти все «решения», которые я мог найти, но безрезультатно.
Файл класса:
@Test(groups = {"customer"}, dataProvider = "customerData", dataProviderClass = Testdata.class, priority = 0)
public void createCustomer(String cName) throws InterruptedException {
System.out.println(cName);
...
}
testng. xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="NAV_Integration_TestSuite">
<test name="Customer creation">
<classes>
<class name="test.customer.CRn"/>
</classes>
</test>
</suite>
readExcel:
public static Object[][] readExcel(String filepath, String sheetName) throws InvalidFormatException, IOException {
FileInputStream file = new FileInputStream(filepath);
XSSFWorkbook wb = new XSSFWorkbook(file);
XSSFSheet sheet = wb.getSheet(sheetName);
int rowCount = sheet.getLastRowNum();
int column = sheet.getRow(0).getLastCellNum();
Object[][] data = new Object[rowCount][column];
for (int i = 1; i <= rowCount; i++) {
XSSFRow row = sheet.getRow(i);
for (int j = 0; j < column; j++) {
XSSFCell cell = row.getCell(j);
DataFormatter formatter = new DataFormatter();
String val = formatter.formatCellValue(cell);
data[i - 1][j] = val;
}
}
wb.close();
return data;
}
pom. xml:
<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>NAV_Integration</groupId>
<artifactId>NAV_Integration</artifactId>
<version>1.0-SNAPSHOT</version>
<name>NAV_Integration</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.version>3.6.0</maven.compiler.version>
<selenium.version>3.14</selenium.version>
<testng.version>6.9.10</testng.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<encoding>UTF-8</encoding>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
.xlsx в кодировке UTF-8. Проект Maven Кодировка текстового файла UTF-8. Я испробовал множество решений, включая различные конфигурации плагинов в pom. xml, настройку переменных среды и различные способы чтения из файла .xlsx.
Затмение: 4,13
Селен: 3,14
TestNG: 6,9,10
Apache POI: 4.1,0