Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Testing Bamboo plugin with Selenium Edited

Hi,

i've written a first small plugin which implements a simple WebPanel by velocity template with some conditions. Now i want to test that those conditions work as expected. Because they were implemented in the template file i believe i'll need something like Selenium to test the real output.

What would be the best way to do that? I've found something similar for Jira here. They have a 'jira-func-test-plugin' which implements some nice test classes with selenium under the hood. Is there something like that for bamboo too?

I'm looking for a good starting point for this kind of tests.

Thanks in advance for your help! 

-----

Update: I've now tried to implement it myself like one would do it normally with Selenium. I added a setter to my test class to get the GeneralConfiguration and from that the baseURL of Bamboo (using GeneralConfiguration.getBaseUrl()).

package it.mypackage.path.package;

import
com.atlassian.bamboo.admin.configuration.GeneralConfiguration;
import com.atlassian.bamboo.admin.configuration.GeneralConfigurationService;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.net.URISyntaxException;

public class BuildResultSeleniumTest {

private
WebDriver driver;
private GeneralConfiguration generalConfiguration;

public BuildResultSeleniumTest(){
driver = new FirefoxDriver();
}

public void setGeneralConfigurationService(GeneralConfigurationService generalConfigurationService){
try {
this.generalConfiguration = generalConfigurationService.getGeneralConfiguration();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}

@Test
public void testImagePresentForCuedBuild(){
String address = (String) generalConfiguration.getBaseUrl();
System.out.println("Address: " + address);
driver.get(address);
}
}

As described here, Injection should work like that.

Unfortunately the variable 'address' remains NULL, so injection seems not work for tests. How do i get the baseURL in a test?

1 answer

1 accepted

0 votes
Answer accepted

It showed out, that i was missing the correct constructor parameters.

The following worked for me:

    private String baseUrl;

    public BuildResultSeleniumTest(ApplicationProperties applicationProperties,
                                   MyPluginComponent pluginComponent){
        this.applicationProperties = applicationProperties;
        this.pluginComponent = pluginComponent;
        this.baseUrl = applicationProperties.getBaseUrl(UrlMode.ABSOLUTE);
    }

 After that i was able to implement Selenium tests as usual..

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

218 views 4 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you