kazurayam / TestNGDataObjectSerializers

A set of Jackson Databind Custom Serializers for the classes of TestNG, such as org.testng.ITestContext and org.testng.ITestResult
Apache License 2.0
0 stars 0 forks source link

develop `com.kazurayam.tesng.ITestContextSerializer` #1

Open kazurayam opened 4 months ago

kazurayam commented 4 months ago

I want to serialize an instance of org.testng.ITestContext into JSON.

kazurayam commented 4 months ago

I have developed

I made a test for it

The test wrote a file

which had the following content:

{
  "implementation-class" : "org.testng.TestRunner",
  "startDate" : "2024-05-20 09:42:07 +0900",
  "name" : "Gradle test",
  "suite" : "Gradle suite",
  "outputDirectory" : "/Users/kazuakiurayama/github/TestngITestContextSerializer/lib/build/reports/tests/test/Gradle suite",
  "allTestMethods" : [ {
    "id" : "",
    "methodName" : "test_ITestContext_toString",
    "qualifiedName" : "com.kazurayam.testng.ITestContextSerializerTest.test_ITestContext_toString"
  }, {
    "id" : "",
    "methodName" : "test_bare_exception",
    "qualifiedName" : "com.kazurayam.testng.ITestContextSerializerTest.test_bare_exception"
  }, {
    "id" : "Test worker@1186339926",
    "methodName" : "test_serialize",
    "qualifiedName" : "com.kazurayam.testng.ITestContextSerializerTest.test_serialize"
  } ],
  "failedTests" : {
    "allMethods" : [ ],
    "allResults" : [ ]
  },
  "passedTests" : {
    "allMethods" : [ {
      "id" : "Test worker@1186339926",
      "methodName" : "test_serialize",
      "qualifiedName" : "com.kazurayam.testng.ITestContextSerializerTest.test_serialize"
    } ],
    "allResults" : [ {
      "name" : "test_serialize",
      "status" : "SUCCESS"
    } ]
  },
  "skippedTests" : {
    "allMethods" : [ ],
    "allResults" : [ ]
  },
  "attributes" : {
    "foo" : "bar",
    "now" : "2024-05-20 09:42:08 +0900"
  }
}

This JSON tells me exactly what information is held in a ITestContext object; very helpful.

I have learned enough about programming using the Jackson ObjectMapper. I can extend the ITestContext more.