tools Flashcards
What is Maven?
Apache Maven is a software project management and comprehension tool that can manage a project’s build, reporting, and documentation from a central piece of information, making it a complete build lifecycle framework.
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
archetypeArtifactId: a starter template to use for creating the basic project structure.
groupId, artifactId, and version: this combination enables you to identify an artifact uniquely. groupId is mostly the company’s domain reversed. For example, groupId of example.com is created as com.example. Version can be in format as ..-. For example, 1.0.0-SNAPSHOT or 1.0.0-RELEASE. Please follow the link for more information.
// Building project and running test mvn clean compile test surefire-report:report
What is Gradle?
Gradle is an open-source build management system that allows you to build any software. It caches dependencies locally and downloads them in parallel.
What is configuration management? #
The framework should be able to read the configurable parameters from any of the sources and be able to change the behaviour of the features provided by the framework. The configuration can be picked up from files like .properties, .ini, .xml, .json, .yml, or .toml, or it can be picked up from the database or any other external sources. This will allow the framework to work independently and free from hard-coding, thus making it more extensible, robust, configurable and easily pluggable with any CI/CD tools.
Configuration hierarchy overview
The framework should bundle the default value for all the configurable parameters in a configuration file.
These default values should be overridable from a project-specific configuration file.
These project-specific configuration parameters should be overridable by passing as a JVM argument (i.e., -Dkey=value).
Designing the configuration manager
The reading of configuration files needs to happen only once. This can be achieved by using the Singleton Pattern for the creation of the file object.
The configuration file can be any of these formats: .properties, .ini, .xml, .json, .yaml, .toml. We can use an appropriate library for reading the configuration files for fetching the configuration parameters.
Configuration overriding
First, the configuration will be looked up in the JVM arguments, so it can be passed from the command line
If the configuration is not passed through the command line, it will be looked up in the project-specific configuration file.
If the configuration parameter is not passed through the command line or a project-specific file, then it will fallback to the default configuration file.
Logback
intended as a successor to the popular log4j project that is used for logging to console and file. The main advantage of using logback over log4j is that its internals has been re-written to perform about ten times faster and has a smaller memory footprint as well.
logback hierarchy of logging levels
ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL
Using Logback in the project
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
LOG.trace(“log trace”);
LOG.trace(“log trace with arguments ‘{}’”, “arg”);
LOG.warn(“log warn”);
LOG.warn(“log warn with arguments ‘{}’”, “arg”);
default TestNG reports
org. testng.reporters.SuiteHTMLReporter – generates a HTML reporter for suites.
org. testng.reporters.FailedReporter – generates testng-failed.xml containing only the failed tests.
org. testng.reporters.XMLReporter – generates summary of test output in xml format.
org. testng.reporters.EmailableReporter2 – generates a single-page HTML report emailable-report.html of the test results.
org. testng.reporters.JUnitReportReporter – generates Junit test output xml for each of the test suites.
We can have our own reporters
by implementing org.testng.IReporter.
Allure Framework
a flexible and lightweight test reporting tool that shows a very concise representation of test execution in a very intuitive web report.
Allure has few annotations for marking the life cycle of test execution.
@Step
@Attachment