Test

Build Maven Standalone Tests

Maven projects are not only used for building standalone or web applications they are also used for providing robust test frameworks using Java.

Running a standalone test is difficult, because the problem is that Maven packages the JAR file with only the main classes or test classes separately without the full dependencies.

The following describes how to create a standalone JAR file with test and main classes as well as all the dependencies.

1. Create a new XML file, e.g. test-jar-with-dependencies.xml, in the project path, e.g. src/main/assembly

2. Edit the test-jar-with-dependencies.xml file and copy

Upload a File Using Selenium WebDriver

Web application testing is not only about the on-screen functionality but also involves interacting with external resources, such as images, documents and other media.

To upload a file using Selenium, the file path is needed to be set in the input element control before submitting the form.

On the form the control to inspect should look like the image below.

Browse... No files selected

When the folder button is clicked the folder dialog is displayed by the browser.

File Upload dialog

The HTML input element should look similar to the code below.
Take note of the type="file" attribute.

<input id="fileUpload"

JMeter Remote Start

JMeter is used to simulate load on a web or network application to collect performance data for analysis.

While developing JMeter scripts are easy enough to do on a standard laptop or desktop, it is not effective to run the tests due to the limitation of resources available.

The limitations could be not having enough processing power, insufficient memory or network bandwidth issues.

It is always good practice to run diagnostic tools while running the JMeter tests to determine bottlenecks to improve the machine hardware or software.

A better solution is to run the script across multiple machines rather than

HP ALM VBScript - Upload the Most Recent File in Folder

Some test artifacts are generated with random names or appended with time-stamps.

This makes it difficult to attach the right file to the test run.

Below is an example to find the latest screenshot file.

REM Upload test screenshot.
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(screenshotPath)
Set recentFile = Nothing
 
REM Search for the latest image file in the folder.
For Each file in folder.Files
   If UCase(fso.GetExtensionName(file.name)) = "PNG" Then
      If (recentFile is Nothing) Then
        Set recentFile = file
      ElseIf (file.DateLastModified > recentFile.DateLastModified) Then
        Set recentFile = file
      End If

JUnit Theory Tests

A Theory JUnit test is a subset of the Parameterized JUnit test feature.

It is very similar in respects to driving tests with a set of test data, except with a few differences as explained below.

  • The test class is annotated with @RunWith(Theories.class)
  • The test does not require a constructor to assign values, which reduces the code length.
  • @DataPoint and @DataPoints annotations are used to indicate that a public static variable as a source of test data.
  • @DataPoint is a single test data value same as @Parameter
  • @DataPoints is a set of test data (iterable object) same as