Skip to content

Commit

Permalink
- Updated unit test to check output value - even failing ones called …
Browse files Browse the repository at this point in the history
…side is not running.
  • Loading branch information
miroslavpojer committed Nov 9, 2023
1 parent 49eff1f commit 6b12344
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package africa.absa.testing.scapi

import munit.FunSuite

import java.io.{ByteArrayOutputStream, PrintStream}

class ScAPIRunnerTest extends FunSuite {

test("call main without params") {
Expand All @@ -26,13 +28,33 @@ class ScAPIRunnerTest extends FunSuite {
}
}

test("call main with minimum params - report of failures") {
test("call main with minimum params - report of failures".only) {
val baos = new ByteArrayOutputStream()
val ps = new PrintStream(baos)
val oldOut = System.out
val oldErr = System.err

System.setOut(ps)
System.setErr(ps)

val args: Array[String] = Array(
"--env", getClass.getResource("/test_project/localhost.env.json").getPath,
"--test-root-path", getClass.getResource("/test_project").getPath)
ScAPIRunner.main(args)

// TODO - add check of generated report presence a and values #13
ps.flush()
System.setOut(oldOut)
System.setErr(oldErr)
val output = baos.toString("UTF-8")
baos.close()
ps.close()

assert(output.contains("* Simple Text Report *"))
assert(output.contains("| getOwners Demo Suite | SKIPPED | 0 | Failure | SKIPPED |"))
assert(output.contains("Before: getOwners Demo Before"))
assert(output.contains("Error: Connection refused"))
assert(output.contains("Test: SKIPPED"))
assert(output.contains("Error: Problems during running before suite logic. Details: Suite-Before for Suite: getOwners Demo Suite has failed methods. Not executing main tests and Suite-After."))
}

test("call main with minimum params - validate only") {
Expand Down

0 comments on commit 6b12344

Please sign in to comment.