BAEL-4631 (#11644)
* BAEL-4631 First code example draft * BAEL-4631 Removed unnecesary constructors Removed unnecessary comments Removed unnecessary test * BAEL-4631 Fixed xml files format * BAEL-4631 Fixing pom.xml and testng.xml indentation
This commit is contained in:
parent
7a5d817a1d
commit
29ebe5e849
|
@ -0,0 +1 @@
|
||||||
|
### Relevant articles
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?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.baeldung.testing_modules</groupId>
|
||||||
|
<artifactId>testng_command_line</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>testing-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testng</groupId>
|
||||||
|
<artifactId>testng</artifactId>
|
||||||
|
<version>${testng.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.beust</groupId>
|
||||||
|
<artifactId>jcommander</artifactId>
|
||||||
|
<version>${com.beust.jcommander.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>jquery</artifactId>
|
||||||
|
<version>${org.webjars.jquery.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>${maven.clean.plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven.compiler.plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven.surefire.plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>ExecuteSingleTest</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>false</skipTests>
|
||||||
|
<includes>
|
||||||
|
<include>**/DateSerializerServiceUnitTest.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>ExecuteTestSuite</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>false</skipTests>
|
||||||
|
<suiteXmlFiles>
|
||||||
|
<suiteXmlFile>testng.xml</suiteXmlFile>
|
||||||
|
</suiteXmlFiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<testng.version>7.4.0</testng.version>
|
||||||
|
<com.beust.jcommander.version>1.81</com.beust.jcommander.version>
|
||||||
|
<org.webjars.jquery.version>3.5.1</org.webjars.jquery.version>
|
||||||
|
<maven.clean.plugin.version>3.1.0</maven.clean.plugin.version>
|
||||||
|
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
|
||||||
|
<maven.surefire.plugin.version>2.22.1</maven.surefire.plugin.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.baeldung.testing_modules.testng_command_line;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class DateSerializerService {
|
||||||
|
public String serializeDate(Date date, String format) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
|
||||||
|
return dateFormat.format(date);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.baeldung.testing_modules.testng_command_line;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@Test(testName = "Date Serializer")
|
||||||
|
public class DateSerializerServiceUnitTest {
|
||||||
|
private DateSerializerService toTest;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public void beforeClass() {
|
||||||
|
toTest = new DateSerializerService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = { NullPointerException.class })
|
||||||
|
void givenNullDate_whenSerializeDate_thenThrowsException() {
|
||||||
|
Date dateToTest = null;
|
||||||
|
|
||||||
|
toTest.serializeDate(dateToTest, "yyyy/MM/dd HH:mm:ss.SSS");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
|
||||||
|
|
||||||
|
<suite name="TestNG command-line" verbose="10">
|
||||||
|
<test name="Date Serializer">
|
||||||
|
<classes>
|
||||||
|
<class
|
||||||
|
name="com.baeldung.testing_modules.testng_command_line.DateSerializerServiceUnitTest" />
|
||||||
|
</classes>
|
||||||
|
</test>
|
||||||
|
</suite>
|
Loading…
Reference in New Issue