Add a Import Statements and Custom Libraries in Version Test Suites
Overview
Java is a versatile and powerful programming language widely used for developing applications across various platforms. One of the key features that make Java so powerful is its extensive standard library and the ability to create and use custom libraries. In this article, we’ll explore how import statements work in Java and how to create and use custom libraries.
Understanding Import Statements
Import statements in Java are used to bring other classes and interfaces into the scope of your program. They allow you to use classes from Java’s standard library, third-party libraries, or your own custom libraries without having to fully qualify the class names.
Syntax
The syntax for an import statement is straightforward:
import package.name.ClassName;
You can also import all the classes from a package using the wildcard*
:
import package.name.*;
Step 1: How to Use and Add Import Statements and Custom Libraries in Codeless.
a) First, create a project and test suites. Then click on the test suite’s version.
Step 2: Add the required import statement and library as per your written codeless scenario.
a) Add your custom Java expression here and immediately import it with the correct Java syntax. Click on “Add Import.”
Note: Currently, we only support Java import syntax statements.
For example:
In a codeless step, how can we use it? let’s see.
So, this custom JavaScript requires certain import statements. Now, we need to add them at the version level.
Step 3: After importing, click the “Add Statement” button, open the test case (TC), and update it. Once you select a test case and run it,.
After execution, you will see on the logs that all necessary imports have been downloaded and are ready to run your test cases.
How to add Custom Libraries in TG suites level.
Custom Libraries:
Maven is a popular build automation tool used primarily for Java projects. It helps manage project dependencies, build processes, and document documentation. Here’s how you can add a Maven dependency to your project.
Step 1: Add Maven to Your Project,
a) Go to Testgrid created project,
b) Click on Test Suites, add a “Add Maven Dependancy” button, and add here on the project structure level.
First, ensure your project is configured to use Maven. Once you add it here, it will be reflected automatically on pom.xml
file.
Step 2: Add dependencies to the testgrid project.
- To add a dependency, you need to specify it in your
pom.xml
file. Dependencies are specified inside the<dependencies>
section. Here’s an example of how to add a dependency:
Step 3: Adding an External JAR
If you have a custom JAR file that is not available in a remote repository, you can add it to your local Maven repository or include it directly in a Codeless TestGrid project.
a) Install the JAR in the Local Repository
Use the following required information and upload the jar to install your local Maven repository on TestGrid.
Happy Testing!