Maven Flashcards
XML
Extensible Markup Language) is a widely-used markup language for representing and exchanging structured data. It provides a way to describe data in a hierarchical format using tags similar to HTML. XML is often used to store and transport data between different systems in a platform-independent manner.
XML Attributes:
provide additional information about the element and are defined within the opening tag of an element.
<book>
</book>
XML Comments
<!-- This is a sample XML document -->
XML Declaration
specifies the version of XML being used and can include an encoding declaration for character encoding.
<?xml version=”1.0” encoding=”UTF-8”?>
<book>
<!-- ... -->
</book>
assertThrows
In JUnit 5, the ____ method is used for asserting that a certain exception is thrown by a piece of code. It’s particularly useful for testing methods that are expected to throw exceptions under specific conditions.
Suppose you have a Calculator class with a method divide that throws an ArithmeticException when attempting to divide by zero
assertThrows - visual
@Test
void testDivideByZero() {
assertThrows(ArithmeticException.class, () -> {
Calculator.divide(10, 0);
});
}
Assertions.fails()
The __ assertion fails a test throwing an AssertionFailedError. It can be used to verify that an actual exception is thrown, or when we want to make a test fail during its development.
Maven lifecycle
- clean: This phase is responsible for cleaning up the output generated from previous builds.
mvn clean
- validate: In this phase, Maven validates the project files, e.g., checking if all required information is available.
- compile: During this phase, Maven compiles the source code of the project.
- test: In the test phase, Maven runs unit tests for the project.
- package: In this phase, Maven packages the compiled code into a distributable format, such as JAR, WAR, or EAR.
- install: The install phase installs the package into the local Maven repository. This allows other projects on the same machine to depend on it.
- deploy: This phase deploys the final package to a remote repository, making it available to other developers or projects.
- verify: The verify phase runs any checks to verify the package is valid and meets quality criteria.
- site: During the site phase, Maven generates project documentation and reports.
- clean site: If you want to clean the previously generated site, you can use this phase.
Surefilre Plugin
used during the test
phase of the build lifecycle to execute the unit tests of an application.
Surefilre Plugin - reports formats
- Plain text files (
.txt
) - XML files (
.xml
)
Surefilre Plugin - goal
This plugin has only one goal, test. This goal is bound to the test phase of the default build lifecycle,and the command mvn testwill execute it.
Surefilre Plugin - configuration
__ can work with the test frameworks JUnit and TestNG. No matter which framework we use, the behavior of surefire is the same.
By default, surefireautomatically includes all test classes whose name starts with Test, or ends with Test, Tests or TestCase.
Maven
Maven is a powerful project management tool by the Apache Group that is based on POM (project object model). The tool provides allows developers to build and document the lifecycle framework.
Build tools
tools or programs that help create an executable application from the source code.