[JAVA-10432] Rename and enable testng-command-line module
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user