Expand my Community achievements bar.

Adobe Developers Live 2021, Session | Custom Functional Tests for safer CI/CD pipelines

Avatar

Administrator

BlogImage.jpg

Session Details

Learn how to deploy your code in production with confidence thanks to custom functional tests. Quality shouldn’t be hard, even on a busy Friday afternoon.

Session Schedule

9-Feb, 11:45 AM - 12:15 PM PST

Speaker(s)

Andres Bott

Full Schedule

Check Here

Q&A

Please use this thread to ask the question related to this Session.

Session FAQs

Q. the tests will be running in parallel? will there be a report showing the results of all the tests run? 

A. the tests are executed as they are shown, so they are not running in parallel. You can use the usual maven reporting functionality to create a proper report for you. | the test results are visible in each Cloud Manager production pipeline execution. 

Q. I sometimes have to mock some AEM api and they fail how to handle those tests 

A. yes, sometimes it is required to mock AEM apis. |  

Q. are functional tests executed against PROD? Or only against stage? 

A. They are executed only against the stage environment before starting the deployment to the prod environment 

Q. Are you planning to provide screenshots of Selenium run within CM pipeline as well? 

A. It will eventually be visible on CM, but I'm not aware that this is currently on the roadmap. 

For now the screenshots can be downloaded as part of the test report. 

Q. During the upgrades or deployments on prod, if we choose to run functional tests before, will it create test content on prod? 

A. The test will run against the stage environment, if the test creates content this will be done on the stage content. Following the best practices, this content should be deleted after the tests have finished  

Don't forget to register yourself for this session using the registration link shared above. 



Kautuk Sahni
7 Replies

Avatar

Level 3

Is the selenium feature in cloud manager available now any documentation for this available on how to set this up and sample test written

Avatar

Employee

Hello, 
Testing UI features with selenium is currently available for our UI tests in Cloud manager.

This is the corresponding documentation page: 

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/using-...

 

And on the AEM archetype you have a starting point for writing UI tests: 

https://github.com/adobe/aem-project-archetype/tree/develop/src/main/archetype/ui.tests

HTH

 

Avatar

Level 1

How to include the component inside it. tests, since there are two separate packages with specific POM.

 

Avatar

Level 1

I tried to test the component's behaviour in it.tests.

Have included the component in the page with CQ.client, Have followed these steps.

1. Created the page with cq.Client.

 

@Rule
public Page root = new Page(cqBaseClassRule.authorRule);​

 

2. If i add Text component from core it was working fine.

 

// this was from import com.adobe.cq.testing.client.components.foundation.Text;       
Text text = componentClient.addComponent(Text.class,root.getPath()+"/jcr:content/root/","responsivegrid/text-test",201);

3. If I tried the same for the custom component, I can't able to do that since it was on another package(ie. core), we can't able to include the model in it.tests from core. so added the 'core' module as a dependency to the "it.tests", then I can able to import the core classes but can't able to create the component as like above.

 

 

Is there any other way to include the component in page with cq.client?

 

Thanks.

Avatar

Employee

hello,

to interact with components using the testing clients, you can use any of the existing component clients here: https://github.com/adobe/aem-testing-clients/tree/aem-cloud/src/main/java/com/adobe/cq/testing/clien...

but for custom components you probably want to create your own client extending AbstractComponent (https://github.com/adobe/aem-testing-clients/blob/aem-cloud/src/main/java/com/adobe/cq/testing/clien...

have a look at the existing components clients to see what they do.

Avatar

Level 1

I am trying to write some functional tests for my components and the below worked for me. I couldnt find any clear documentation, so I think this is how it can be done.

 

1. Create a class "MyComponent" that extends com.adobe.cq.testing.client.components.AbstractComponent

2. Add the constructor that calls the super constructor like this 

    public MyComponent(ComponentClient client, String pagePath, String location, String nameHint) {

        super(client, pagePath, location, nameHint);

    }

3. Override the getResourceType() method to your component resourceType

    public String getResourceType() {

         return "/my-project/components/mycomponent";

    }

4. Now you can add your component to the page like below

    MyComponent comp = new MyComponent(componentClient, root.getPath, "/jcr:content/root", "mycomp");

    comp.create("", 201);

    comp.setProperty("prop1", "value for the prop");

    comp.save(200);

Now that we have added the component and configured a property, the assertion can be done as explained in this video https://www.youtube.com/watch?v=yJX6r3xRLHU