Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Feature/spike jacoco numbers #49

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-check-jacoco.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
}
}