Permalink
Browse files

Fix TestJSONFormatter

use “assertThrows”
  • Loading branch information...
ZhangMan1126 committed Aug 30, 2018
1 parent 87b2cd0 commit 1faa4348844613ae1a1dc14a7487c3de77ad05cc
Showing with 21 additions and 12 deletions.
  1. +21 −12 core/src/test/kotlin/org/evomaster/core/outputformatter/TestJSONFormatter.kt
@@ -1,32 +1,41 @@
package org.evomaster.core.outputformatter
import org.evomaster.core.output.formatter.MismatchedFormatException
import org.evomaster.core.output.formatter.OutputFormatter
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.assertThrows
class TestJSONFormatter {
@Test
fun test(){
assertTrue(OutputFormatter.getFormatters()?.size == 1 ?:false)
var body = "{" +
"\"authorId\":\"VZyJz8z_Eu2\", " +
"\"creationTime\":\"1921-3-13T10:18:56.000Z\", " +
"\"newsId\":\"L\"" +
"}";
print(OutputFormatter.JSON_FORMATTER.getFormatted(body))
val body = """
{
"authorId": "VZyJz8z_Eu2",
"creationTime": "1921-3-13T10:18:56.000Z",
"newsId": "L"
}
"""
OutputFormatter.JSON_FORMATTER.getFormatted(body)
}
@Test
fun testMismatched(){
assertTrue(OutputFormatter.getFormatters()?.size == 1 ?:false)
var body =
"\"authorId\":\"VZyJz8z_Eu2\", " +
"\"creationTime\":\"1921-3-13T10:18:56.000Z\", " +
"\"newsId\":\"L\"" +
"}";
print(OutputFormatter.JSON_FORMATTER.getFormatted(body))
val body = """
"authorId": "VZyJz8z_Eu2",
"creationTime": "1921-3-13T10:18:56.000Z",
"newsId": "L"
}
"""
assertThrows<MismatchedFormatException>{
OutputFormatter.JSON_FORMATTER.getFormatted(body)
}
}
}

0 comments on commit 1faa434

Please sign in to comment.