Running Tests With TestProject

After we have written some tests with TestProject, the odds are that we want to run them. This blog post helps us to solve this problem. After we have finished this blog post, we:

  • Can create a project that contains our test cases.
  • Know how we can add tests to a project.
  • Can run individual tests on-demand.
  • Understand how we can run our tests by using TestProject jobs.

Let's start by creating a new project.

This blog post is the fourth part of my TestProject tutorial that is sponsored by TestProject.io. However, the views and opinions expressed in this tutorial are mine.

This blog post assumes that:

By the way, you might want to read the other parts of my TestProject tutorial.

Creating a New Project

We can create a new project by following these steps:

First, we have to create a new project. After we have logged in, we should see the 'Home' page of the app.testproject.io website. When we are viewing this page, we can create a new project by using these two options:

  • If we have no projects, we can create a new project by clicking the 'Add a Project' button. Note that this button is visible only if we haven't created any projects.
  • If we already have projects, we can create a new project when we create a new test or upload a test package. We will talk more about this in the next section of this blog post.

The following figure illustrates the first option:

Second, when we click the 'Add a Project' button, the app.testproject.io website opens a modal dialog that allows us to enter the name and an optional description of our project. After we have entered this information, we can create a new project by clicking the 'Create' button.

The following figure illustrates the opened modal dialog:

After we have created a new project, the app.testproject.io website displays the 'Project' page. Let's move on and find out how we can add tests to our project.

Adding Tests to a Project

As we remember, a project is a collection of test cases. This means that we cannot run our test cases before we have added them to a project. We can add new tests to a project by using one of these two options:

  • We can click the the 'NEW TEST' button that is visible on every page of the app.testproject.io website.
  • We can navigate to the 'Tests' view of the 'Project' page and add our tests from that view.

Next, we will take a closer look at these options.

Using the New Test Button

When we click the 'NEW TEST' button, the app.testproject.io website opens a 'Create a new test' wizard that allows us to add tests to the specified project.

The following figure identifies the location of the 'NEW TEST' button:

After we have opened the 'Create a new test’ wizard, we naturally have to finish it.

Adding Tests from the Tests View

If we want to open the 'Tests' view of the 'Project' page and add our tests from that view, we have to follow these steps:

First, we have to open the 'Tests' view of the 'Project' page. If we have just created the project, the app.testproject.io website should display this view. However, if we created the project earlier, we can open this view by following these steps:

  1. Open the 'Home' page. This page has a 'My Projects' section that contains a list of our projects.
  2. Click the name of the project.

The following figure illustrates the project list that is shown on the 'Home' page:

Second, we have to open the 'Create a new test' wizard by using one of these three options:

  • We can click the 'Add a new test' link.
  • If our project has no tests, we can click the 'Create a test' button.
  • We can click the 'NEW TEST' button.

The following figure illustrates these options:

When we click either the 'Add a new test' link, the 'Create a test' button, or the 'NEW TEST' button, the app.testproject.io website opens the 'Create a new test' wizard. Let's move on and find out how we can finish this wizard.

Finishing the Create a New Test Wizard

We can finish the 'Create a new test' wizard by following these steps:

First, we have to specify the following information:

  • The type of the added test.
  • The project that contains the added tests.

We can provide the required information by using one of these two options:

If we started the 'Create a new test' wizard from the 'Project' page, we don't have to specify the target project. We can simply select the type of the added test. Because we want to upload tests which we wrote in the previous part of this tutorial, we will have to select the 'Code' option. After we have selected the type of the added test, we can proceed to the next step by clicking the 'Next' button.

The following figure illustrates this option:

On the other hand, if we didn't start the 'Create a new test' wizard from the 'Project' page, we have to also specify the target project by using the projects UI component. When we specify the target project, we can either choose an existing project or create a new project.

The following figure illustrates this option:

After we have selected the target project, we can proceed to the next step of the 'Create a new test' wizard by clicking the 'Next' button.

The following figure demonstrates how we can finish the first step of the 'Create a new test' wizard:

Second, we have to upload the jar file that contains our tests. We can upload our file by following these steps:

  1. Drag the jar file to the upload file area found from the modal dialog.
  2. Click the 'Upload File' button

The following figure illustrates this step:

Third, we have to review the tests which are added to the created test package. If everything looks fine, we can proceed to the final step of the wizard by clicking the 'Next' button.

The following figure illustrates this step:

This step displays the name of the test which we configured by using the @Test annotation. If our test class is not annotated with this annotation, this step uses the name of the test class as the name of the test.

Fourth, we have to create the test package that contains our tests. When we create a new test package, we have to provide the following information:

  • The type of the application which is tested by our tests. Because we have written tests for a web application, we have to select the 'Web' option.
  • The name of the created test package.
  • An optional description

After we have provided the required information, we can proceed to the next step of the wizard by clicking the 'Next' button.

The following figure illustrates this step:

Fifth, we have to create the test package and add our tests to the created package by clicking the 'Start Testing' button.

The following figure illustrates this step:

After we have created a new test package, the app.testproject.io website displays the 'Tests' view of the 'Project' page which should display our new test package.

The following figure illustrates this situation:

We can now add tests to a project. However, we still don't know how we can run these tests. Next, we will find out how we can run individual tests.

Running Individual Tests

When we want to run an individual test, we have to navigate to the 'Tests' view of the 'Project' page. We can do this by opening the 'Project' page (The 'Tests' view is shown when we open the 'Project' page). We can also open this view by clicking the 'Tests & Jobs' link found from the 'Project' page.

Before we can run an individual test, we have to select the test package which contains our test. We can do this by clicking the name of the test package.

The following figure demonstrates this step:

After we have opened our test package, we should see a list of tests which belong to this test package. When we want to run one of these tests, we have to follow these steps:

  1. Move the mouse cursor over the HTML element which displays the name of the test.
  2. Click the 'Run' button.

The following figure identifies the location of the 'Run' button:

When we click the 'Run' button, the app.testproject.io website opens either a modal dialog or a wizard which allows us to configure the invoked test. Next, we will learn to:

  • Run a test that has no input parameters.
  • Override input parameter values passed to the invoked test.
  • Provide input parameter values by using a data source.

Let's start by running a test that has no input parameters.

Running a Test That Has No Input Parameters

If our test has no input parameters, we can run it by following these steps:

  1. Select the TestProject agent that runs our test. Note that this drop-down list contains all running TestProject agents which are associated with our user account.
  2. Because we are a running a web test, we have to select the web browser that runs our test.
  3. Run our test by clicking the 'Run' button.

The following figure illustrates the modal dialog that allows us to run our test:

Next, we will find out how we can run a test that has input parameters.

Running a Test That Has Input Parameters

If our test has input parameters, we can run it by following these steps:

First, we have to select the TestProject agent and web browser which run our test. After we have made these choices, we have to move to the next step of this wizard by clicking the 'Next' button.

The following figure illustrates this step:

Second, we have to configure the parameter values which are passed to our test. If we specified default values when we configured our input parameters by using the @TestParameter annotation, these default values are shown on the form displayed on the modal dialog. If we want to override these default values, we can simply make the required changes to the form.

After we have configured the values of our input parameters, we can run our test by clicking the 'Run' button.

The following figure illustrates this step:

If we have multiple tests which use the same input parameters or our test has a lot of input parameters, it is not very practical to configure the parameter values manually. Next, we will find out how we can provide these parameter values by using a data source.

Providing Input Parameters With a Data Source

If we want to run a test that has input parameters and provide the values of these parameters by using a data source, we have to follow these steps:

First, we have to create the CSV file that specifies the parameter values of our input parameters. We can create this CVS file by following these rules:

  • The first line of the CSV file must specify the names of our input parameters.
  • The second line of the CSV file contain the parameter values of our input parameters.
  • We have to use one of the following characters as a separator character: ',', ';', '|' or '/t'.

After we have created our CSV file (testproject-data.csv), its content looks as follows:

expectedTitle,url
Petri Kainulainen — Developing Software With Passion,https://www.petrikainulainen.net

Second, we have to select the TestProject agent and web browser which run our test. After we have made these choices, we have to move to the next step of this wizard by clicking the 'Next' button.

The following figure illustrates this step:

Third, we have to toggle the option that allows us to use a data source when we provide the parameter values of the required input parameters. After we have enabled this option, we can select the used data source from the 'Select Data Source' drop-down list. However, because we haven't created a data source, we have to create a new data source by clicking the 'Add data source' link.

The following figure illustrates this step:

Fourth, we have to configure the created data source. When we configure our data source, we have to provide the following information:

  • The name of the data source.
  • An optional description of the data source.
  • The separator character. If we don't want to use the default separator character (comma), we can change the separated character by clicking the 'CSV Advanced' link.
  • The CSV file that contains the test data. We can provide this CSV file by simply dropping the uploaded CSV file to the upload area.

After we have configured the created data source, we can create a new data source by clicking the 'Create' button.

The following figure illustrates this step:

Fifth, we can run our test by clicking the 'Run' button. Also, if we want to ensure that our test uses the created data source, we have to take a look at the selected value of the 'Select Data Source' drop-down list.

The following figure illustrates this step:

We can now run individual tests with TestProject. However, if we want to run multiple tests, it's not very practical to run them one by one. Let's move on and find out how we can solve this problem.

Running Our Tests With a Job

If we want to run multiple tests, it's a good idea to create a job that runs our tests. When we want to create a new job, we have to open the 'Project' page. After we have opened this page, we have to open the 'Create a new job' wizard by using one of these two options:

  • We can click the 'Add a new job' link.
  • If our project has no jobs, we can click the 'Add a job' button.

The following figure illustrates these options:

After we have opened the 'Create a new job' wizard, we can create a new job by following these steps:

First, we have to provide the name and an optional description of our job. After we have provided the required information, we can proceed to the next step of this wizard by clicking the 'Next' button.

The following figure illustrates this step:

Second, we have to configure the execution environment of our job. When we do this, we have to provide the following information:

  • The type of the invoked tests. Because we want to run web tests, we have to click the 'Web' icon.
  • The TestProject agent that runs our tests. Note that the drop-down list contains all TestProject agents which are associated with our user account.

After we have configured the execution environment of our job, we can proceed to the next step of this wizard by clicking the 'Next' button.

The following figure illustrates this step:

Fourth, we have to configure the web browsers which run our tests. Because we want to run our tests by using the 'Chrome' web browser, we have to click the 'Chrome' checkbox. After we have selected the web browser, we can proceed to the next step of this wizard by clicking the 'Next' button.

The following figure illustrates this step:

You can run your tests by using any browser that is installed to the computer which runs your tests. If you want to run your tests on multiple web browsers, you can simply select the preferred browsers in this step, and the TestProject agent will run your tests by using all selected web browsers.

Fifth, we have to schedule our job by using one of these three options:

If we want to run our job on demand, we have select the 'On demand' option and create our job by clicking the 'Finish' button.

The following figure illustrates the scheduling configuration of our job:

If we want to run our job only once, we have to select the 'One time' option and schedule our job execution by providing the following information: time zone, date, and time. After we have scheduled our job execution, we can create our job by clicking the 'Finish' button.

The following figure illustrates the scheduling configuration of our job:

If we want to run our job at a specific time, we have to select the 'Recurrent' option and schedule our job execution by providing the following information: time zone, week days, hours, and minutes. After we have scheduled our job execution, we can create our job by clicking the 'Finish' button.

The following figure illustrates the scheduling configuration of our job:

After we have created a new job, the job list component shown on the 'Project' page should contain our next job. The following figure illustrates this situation:

After we have created a new job, we have to configure the tests which are invoked when our job is run. We can do this by following these steps:

First, we have to open the 'Tests' view of the 'Project' page. After we have opened this view, we have to click the name of the test package that contains the tests which are added to our job.

The following figure illustrates this step:

Second, we have to add the invoked tests to our job. We can do this by dragging the invoked tests to our job.

The following figure illustrates this step:

After we have added two tests to our job, our job list item should have a small icon that identifies the number of invoked tests (in our case, our job has two tests). The following figure identifies the location of this icon:

If we want to see the tests of a job, we can simply click the name of the job. After we have done this, our job list item will look as follows:

We can also remove tests from the job. If we want to remove a test from a job, we have to move the mouse cursor over the removed test and click the 'Remove test from job' icon.

The following figure identifies the location of this icon:

If our job has a test which has input parameters and we want to override the default values of these parameters, we have to select the data source that provides the required parameters values to our test. We can do this by following these steps:

First, we have to open the 'Select Data Source' model dialog by clicking the data source icon.

The following figure illustrates this step:

Second, we have to select the used data source by using the 'Select Data Source' drop-down list. This list contains all data sources of our project. After we have selected the used data source, we have to save our selection by clicking the 'Update' button.

The following figure illustrates this step:

After we have configured the used data source, the color of the data source icon will change from grey to blue. The following figure illustrates this situation:

We are done. The TestProject framework can finally run our job at the scheduled time. However, if we created a job that is run on demand, we have to run it manually. We can run our job by moving the mouse cursor over the name of our job and clicking the 'Run' icon.

The following figure identifies the location of the 'Run' icon:

We can now create new projects, add tests to our projects, and run our tests. Let's summarize what we learned from this blog post.

Summary

This blog post has taught us eight things:

  • If we want to run tests with TestProject, we have to create a project that contains our test cases.
  • Before we can run our tests, we have to upload the jar file (aka a test package) that contains the invoked tests.
  • We can run individual tests from the 'Test Package' page.
  • If we want to run multiple tests, we have to create a job that runs our tests.
  • We can run jobs on any agent that is associated with our user account.
  • We can run jobs on multiple browsers.
  • We can run our jobs on-demand or schedule them to run only once or at a specific time (recurrent execution).
  • We can upload data sources to app.testproject.io website and create data-driven tests with input parameters.
1 comment… add one

Leave a Reply