[JAVA-10432] Rename and enable testng-command-line module

This commit is contained in:
Haroon Khan
2022-03-04 21:17:23 +00:00
parent 8c63a8e145
commit 2bdc9bf90d
6 changed files with 8 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
package com.baeldung.testng;
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);
}
}

View File

@@ -0,0 +1,24 @@
package com.baeldung.testng;
import java.util.Date;
import com.baeldung.testng.DateSerializerService;
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");
}
}