Skip to content

Commit 1fcb219

Browse files
BAEL-4631 (eugenp#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
1 parent 9ef74e2 commit 1fcb219

File tree

5 files changed

+160
-0
lines changed

5 files changed

+160
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
### Relevant articles
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.baeldung.testing_modules</groupId>
8+
<artifactId>testng_command_line</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>testing-modules</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.testng</groupId>
19+
<artifactId>testng</artifactId>
20+
<version>${testng.version}</version>
21+
<scope>test</scope>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.beust</groupId>
25+
<artifactId>jcommander</artifactId>
26+
<version>${com.beust.jcommander.version}</version>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.webjars</groupId>
31+
<artifactId>jquery</artifactId>
32+
<version>${org.webjars.jquery.version}</version>
33+
<scope>test</scope>
34+
</dependency>
35+
</dependencies>
36+
37+
<build>
38+
<pluginManagement>
39+
<plugins>
40+
<plugin>
41+
<artifactId>maven-clean-plugin</artifactId>
42+
<version>${maven.clean.plugin.version}</version>
43+
</plugin>
44+
<plugin>
45+
<artifactId>maven-compiler-plugin</artifactId>
46+
<version>${maven.compiler.plugin.version}</version>
47+
</plugin>
48+
<plugin>
49+
<artifactId>maven-surefire-plugin</artifactId>
50+
<version>${maven.surefire.plugin.version}</version>
51+
<configuration>
52+
<skipTests>true</skipTests>
53+
</configuration>
54+
</plugin>
55+
</plugins>
56+
</pluginManagement>
57+
</build>
58+
59+
<profiles>
60+
<profile>
61+
<id>ExecuteSingleTest</id>
62+
<activation>
63+
<activeByDefault>true</activeByDefault>
64+
</activation>
65+
<build>
66+
<pluginManagement>
67+
<plugins>
68+
<plugin>
69+
<artifactId>maven-surefire-plugin</artifactId>
70+
<configuration>
71+
<skipTests>false</skipTests>
72+
<includes>
73+
<include>**/DateSerializerServiceUnitTest.java</include>
74+
</includes>
75+
</configuration>
76+
</plugin>
77+
</plugins>
78+
</pluginManagement>
79+
</build>
80+
</profile>
81+
82+
<profile>
83+
<id>ExecuteTestSuite</id>
84+
<activation>
85+
<activeByDefault>true</activeByDefault>
86+
</activation>
87+
<build>
88+
<pluginManagement>
89+
<plugins>
90+
<plugin>
91+
<artifactId>maven-surefire-plugin</artifactId>
92+
<configuration>
93+
<skipTests>false</skipTests>
94+
<suiteXmlFiles>
95+
<suiteXmlFile>testng.xml</suiteXmlFile>
96+
</suiteXmlFiles>
97+
</configuration>
98+
</plugin>
99+
</plugins>
100+
</pluginManagement>
101+
</build>
102+
</profile>
103+
</profiles>
104+
<properties>
105+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
106+
<maven.compiler.source>1.8</maven.compiler.source>
107+
<maven.compiler.target>1.8</maven.compiler.target>
108+
<testng.version>7.4.0</testng.version>
109+
<com.beust.jcommander.version>1.81</com.beust.jcommander.version>
110+
<org.webjars.jquery.version>3.5.1</org.webjars.jquery.version>
111+
<maven.clean.plugin.version>3.1.0</maven.clean.plugin.version>
112+
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
113+
<maven.surefire.plugin.version>2.22.1</maven.surefire.plugin.version>
114+
</properties>
115+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.testing_modules.testng_command_line;
2+
3+
import java.text.SimpleDateFormat;
4+
import java.util.Date;
5+
6+
public class DateSerializerService {
7+
public String serializeDate(Date date, String format) {
8+
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
9+
return dateFormat.format(date);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.baeldung.testing_modules.testng_command_line;
2+
3+
import java.util.Date;
4+
5+
import org.testng.annotations.BeforeClass;
6+
import org.testng.annotations.Test;
7+
8+
@Test(testName = "Date Serializer")
9+
public class DateSerializerServiceUnitTest {
10+
private DateSerializerService toTest;
11+
12+
@BeforeClass
13+
public void beforeClass() {
14+
toTest = new DateSerializerService();
15+
}
16+
17+
@Test(expectedExceptions = { NullPointerException.class })
18+
void givenNullDate_whenSerializeDate_thenThrowsException() {
19+
Date dateToTest = null;
20+
21+
toTest.serializeDate(dateToTest, "yyyy/MM/dd HH:mm:ss.SSS");
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
2+
3+
<suite name="TestNG command-line" verbose="10">
4+
<test name="Date Serializer">
5+
<classes>
6+
<class
7+
name="com.baeldung.testing_modules.testng_command_line.DateSerializerServiceUnitTest" />
8+
</classes>
9+
</test>
10+
</suite>

0 commit comments

Comments
 (0)