Testing Alfresco extensions
(no, it’s not about jUnit)

07/11/2013
Alexey Ermakov / ITD Systems

#SummitNow
2

What’s the target?
•
•
•
•

REST APIs tests
UI tests
complex behavioral scenarios
easy-to-write tests

#SummitNow
#Summ...
3

Why?

There’s Alfresco SDK and jUnit that already
allow you to run tests with repository
embedded to your Java code.

#...
4

Because we can!

#SummitNow
#SummitNow
5

What’s inside?
• Python as the main tests language
• Proboscis as a core testing framework
• Selenium as a web browser ...
6

But where is your framework?
Repository tests:
• Python wrappers for REST calls
• Out-of-the-box implementation for few...
7

Example
from pyalfresco import alfresco
from proboscis.asserts import assert_equal
alf = alfresco.Alfresco()
assert_equ...
8

Example
def get_task(self, id):
return WrapperObject(
self,
**self.repo_get_json(
'api/task-instances/%s' % id
)
)

#Su...
9

OK, what’s about UI tests?
UI tests:
• Predefined classes and decorators to run
tests only for specific browsers

#Summ...
10

OK, what’s about UI tests?
UI tests:
• Predefined classes and decorators to run
tests only for specific browsers
• Pre...
11

Example
from pyalfresco.tests import *
@for_browsers(['ie', 'firefox'])
class DashletTest(AlfrescoShareTest):
pass

#S...
12

Dashlet to test

#SummitNow
#SummitNow
13

Workflow start form

#SummitNow
#SummitNow
14

Testing dashlet
class WorkflowShortcutsDashlet(AlfrescoShareObject):
def locate(self):
self.el = self.driver.find_elem...
15

Testing dashlet
@test
def locate_dashlet(self):
self.perform_share_log_in('admin', 'admin')
self.driver.get(URL + '/pa...
16

Testing dashlet
@test(depends_on=[locate_dashlet])
def launch_workflows(self):
for w in self.dashlet.get_workflows().k...
17

Testing form
<appearance>
<field id="bpm:workflowDescription" />
<field id="bpm:assignee">
<control template="/orgchar...
18

Testing form
f = AlfrescoShareWorkflowForm(
workflow_id='activiti$wf', parent=self, fields=[
{
'name': 'bpm:workflowDe...
19

Testing form
tffc = f.get_field_control('bpm:workflowDescription')
tffc.set_text('DESCRIPTION')
ocfc = f.get_field_con...
20

Hm, what about complex tests?
1.
2.
3.
4.
5.

Create UI test
Verify results with REST bindings
Perform REST APIs tests...
21

Roadmap
• More wrappers for REST APIs
• More predefined form controls
• Improvements to framework code

#SummitNow
#Su...
22

Stay in touch
Follow us: @itdsystems
Join the project: http://git.io/qzeE1Q

#SummitNow
#SummitNow
Upcoming SlideShare
Loading in...5
×

Testing Alfresco extensions

411

Published on

Presentation from Alfresco Summit 2013

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
411
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Testing Alfresco extensions

  1. 1. Testing Alfresco extensions (no, it’s not about jUnit) 07/11/2013 Alexey Ermakov / ITD Systems #SummitNow
  2. 2. 2 What’s the target? • • • • REST APIs tests UI tests complex behavioral scenarios easy-to-write tests #SummitNow #SummitNow
  3. 3. 3 Why? There’s Alfresco SDK and jUnit that already allow you to run tests with repository embedded to your Java code. #SummitNow #SummitNow
  4. 4. 4 Because we can! #SummitNow #SummitNow
  5. 5. 5 What’s inside? • Python as the main tests language • Proboscis as a core testing framework • Selenium as a web browser emulator #SummitNow #SummitNow
  6. 6. 6 But where is your framework? Repository tests: • Python wrappers for REST calls • Out-of-the-box implementation for few standard REST APIs #SummitNow #SummitNow
  7. 7. 7 Example from pyalfresco import alfresco from proboscis.asserts import assert_equal alf = alfresco.Alfresco() assert_equal( alf.get_person('admin').firstName, 'Administrator‘) #SummitNow #SummitNow
  8. 8. 8 Example def get_task(self, id): return WrapperObject( self, **self.repo_get_json( 'api/task-instances/%s' % id ) ) #SummitNow #SummitNow
  9. 9. 9 OK, what’s about UI tests? UI tests: • Predefined classes and decorators to run tests only for specific browsers #SummitNow #SummitNow
  10. 10. 10 OK, what’s about UI tests? UI tests: • Predefined classes and decorators to run tests only for specific browsers • Predefined APIs to interact with Alfresco Share forms system #SummitNow #SummitNow
  11. 11. 11 Example from pyalfresco.tests import * @for_browsers(['ie', 'firefox']) class DashletTest(AlfrescoShareTest): pass #SummitNow #SummitNow
  12. 12. 12 Dashlet to test #SummitNow #SummitNow
  13. 13. 13 Workflow start form #SummitNow #SummitNow
  14. 14. 14 Testing dashlet class WorkflowShortcutsDashlet(AlfrescoShareObject): def locate(self): self.el = self.driver.find_element_by_css_selector( '.dashlet.workflow-shortcuts‘ ) #SummitNow #SummitNow
  15. 15. 15 Testing dashlet @test def locate_dashlet(self): self.perform_share_log_in('admin', 'admin') self.driver.get(URL + '/page/user/admin/dashboard') self.dashlet = WorkflowShortcutsDashlet( parent=None, driver=self.driver ) self.dashlet.locate() #SummitNow #SummitNow
  16. 16. 16 Testing dashlet @test(depends_on=[locate_dashlet]) def launch_workflows(self): for w in self.dashlet.get_workflows().keys(): self.dashlet.launch_workflow(w) #SummitNow #SummitNow
  17. 17. 17 Testing form <appearance> <field id="bpm:workflowDescription" /> <field id="bpm:assignee"> <control template="/orgchart-picker.ftl" /> </field> </appearance> #SummitNow #SummitNow
  18. 18. 18 Testing form f = AlfrescoShareWorkflowForm( workflow_id='activiti$wf', parent=self, fields=[ { 'name': 'bpm:workflowDescription', 'control': AlfrescoShareFormTextFieldControl }, ... ]) #SummitNow #SummitNow
  19. 19. 19 Testing form tffc = f.get_field_control('bpm:workflowDescription') tffc.set_text('DESCRIPTION') ocfc = f.get_field_control('bpm:assignee') ocfc.show_picker() ocfc.search('admin') ocfc.add_person('Administrator') ocfc.close_picker() f.submit() #SummitNow #SummitNow
  20. 20. 20 Hm, what about complex tests? 1. 2. 3. 4. 5. Create UI test Verify results with REST bindings Perform REST APIs tests … PROFIT!! #SummitNow #SummitNow
  21. 21. 21 Roadmap • More wrappers for REST APIs • More predefined form controls • Improvements to framework code #SummitNow #SummitNow
  22. 22. 22 Stay in touch Follow us: @itdsystems Join the project: http://git.io/qzeE1Q #SummitNow #SummitNow
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×