Creating a new module / plugin⚓︎
This article describes how to create a new QTAF module. Module bündeln den Code von Plugins oder Bibliotheken. Beispiele für existierende QTAF-Module sind qtaf-allure-plugin
, qtaf-xray-plugin
, qtaf-io
, qtaf-http
.
Prerequisites⚓︎
- Clone the QTAF repository to your PC.
- Make sure that GPG is installed on your PC. Prüfen Sie dies mit dem Befehl
gpg --version
. Wenn GPG nicht installiert ist befolgen Sie diese Anleitung, um GPG zu installieren - First install QTAF locally. You can find the corresponding instructions here
Create a new module⚓︎
- open the QTAF project in IntelliJ
- click on
File > New > Module
in the menu - then select
Maven Archetype
in the left side menu. You will then be asked for the name, the GroupId, the ArtifactId and the version number of the new module. For GroupId selecten.qytera
, the ArtifactId can be freely selected. The name of the module should be identical to the ArtifactId and the version number identical to the version number of the parent moduleqtaf
. Then click on the "Finish" button. A new folder should then have been created in the project with the name of the new module. In this folder you will find the POM file of the new module. 4. - add the
qtaf-core
dependency to the POM file of the new module 5 After the local installation, you can integrate the new module as a dependency in a local project. - create the packages
en.qytera.qtaf.<modulename>
in thesrc/main/java
folder of your new module, whereby<modulename>
can be freely selected by you. However, the package<modulename>
must be in the packageen.qytera.qtaf
. Otherwise, dependency injections of the QTAF framework will not work, as certain classes such as EventSubscriber are always searched for in packages that are in the namespaceen.qytera.qtaf
. You can create the new directories by right-clicking on your module folder in the QTAF project. After right-clicking, navigate to New > Directory. Then select the four standard directories and click Enter. - create another package called event_subscriber in the
<modulename>
package - create a class in the package
event_subscriber
that implements the interfaceIEventSubscriber
of the QTAF framework. Using the event subscriber, plug-ins can react to events generated by the QTAF framework. For example, you can subscribe to thebeforeLogsPersisted
event to process the data of the current test run. You can use the following sample code to display a message on the console as soon as the data is available:
Further information about the QTAF event system can be found in this article. You can now implement your own logic for processing the test data within the
onBeforeLogsPersisted
method. An exemplary (albeit not very useful) method would be to output all names of test features and test scenarios as well as all associated log messages to the console. This would look like this:
9. now you can install the new module locally with the command
mvn clean install
. You can use a temporary version number such as LOCAL_2023_01_01-001
for the local version. You can find more information on this in this article.
10. now integrate the new module into a test project via the POM file. The dependency for our example module would look like this:
TestRunner
class in your test project. You will see that our new module now generates an output on the console.