diff --git a/.github/workflows/ci-check-jacoco.yml b/.github/workflows/ci-check-jacoco.yml index ac5c5ec..e307f7c 100644 --- a/.github/workflows/ci-check-jacoco.yml +++ b/.github/workflows/ci-check-jacoco.yml @@ -19,7 +19,7 @@ jobs: run: sbt jacoco - name: Add coverage to PR id: jacoco - uses: madrapps/jacoco-report@v1.3 + uses: madrapps/jacoco-report@v1.6.1 with: paths: > ${{ github.workspace }}/testApi/target/scala-2.13/jacoco/report/jacoco.xml diff --git a/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner.scala b/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner.scala index 1ce8930..9455363 100644 --- a/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner.scala +++ b/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner.scala @@ -74,6 +74,16 @@ object ScAPIRunner { } } + def newMethod(): Unit = { + val decision = true + if (decision) { + Logger.info("I am always here") + } else { + Logger.info("Never see me here") + } + Logger.info(s"We meet here at final") + } + def main(args: Array[String]): Unit = { val output = run(args) Logger.info(s"ScAPI Runner output:\n$output") diff --git a/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner2.scala b/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner2.scala new file mode 100644 index 0000000..cd742ef --- /dev/null +++ b/testApi/src/main/scala/africa/absa/testing/scapi/ScAPIRunner2.scala @@ -0,0 +1,91 @@ +/* + * Copyright 2023 ABSA Group Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package africa.absa.testing.scapi + +import africa.absa.testing.scapi.config.ScAPIRunnerConfig +import africa.absa.testing.scapi.json.Environment +import africa.absa.testing.scapi.json.factory.{EnvironmentFactory, SuiteFactory} +import africa.absa.testing.scapi.logging.Logger +import africa.absa.testing.scapi.model.suite.{Suite, SuiteResult} +import africa.absa.testing.scapi.reporter.StdOutReporter +import africa.absa.testing.scapi.rest.RestClient +import africa.absa.testing.scapi.rest.request.sender.ScAPIRequestSender +import africa.absa.testing.scapi.suite.runner.SuiteRunner +import org.apache.logging.log4j.Level + +import java.nio.file.{Files, Paths} +import scala.util.{Failure, Success} + +/** + * Object `ScAPIRunner` serves as the main entry point for the ScAPI runner. + */ +object ScAPIRunner2 { + + + /** + * The main method that is being invoked to run the ScAPI runner. + * + * @param args Command-line arguments. + */ + def run(args: Array[String]): String = { + val cmd = ScAPIRunnerConfig.getCmdLineArguments(args) match { + case Success(value) => value + case Failure(exception) => throw exception + } + + System.setProperty("log4j.configurationFile", "log4j2.xml") + cmd match { + case c if c.trace => Logger.setLevel(Level.TRACE) + case c if c.debug => Logger.setLevel(Level.DEBUG) + case _ => Logger.setLevel(Level.INFO) + } + cmd.logConfigInfo() + + val suitesPath = Paths.get(cmd.testRootPath, "suites") + if (!Files.exists(suitesPath)) throw SuiteLoadFailedException("'suites' directory have to exist in project root.") + + // jsons to objects + val environment: Environment = EnvironmentFactory.fromFile(cmd.envPath) + val suiteBundles: Set[Suite] = SuiteFactory.fromFiles(environment, suitesPath, cmd.filter, cmd.fileFormat) + SuiteFactory.validateSuiteContent(suiteBundles) + + // run tests and result reporting - use categories for test filtering + if (cmd.validateOnly) { + Logger.info("Validate only => end run.") + "" + } else { + Logger.info("Running tests") + val suiteResults: List[SuiteResult] = SuiteRunner.runSuites(suiteBundles, environment, () => new RestClient(ScAPIRequestSender)) + StdOutReporter.printReport(suiteResults) + } + } + + def newMethod(): Unit = { + val decision = true + if (decision) { + Logger.info("I am always here") + } else { + Logger.info("Never see me here") + } + Logger.info(s"We meet here at final") + } + + def main(args: Array[String]): Unit = { + val output = run(args) + Logger.info(s"ScAPI Runner output:\n$output") + } +}