SlideShare a Scribd company logo
Plugin Testing



Thursday, October 22, 2009
Plugin Testing



Thursday, October 22, 2009
Plugin Testing
                                            her stuff
                                  gins & ot
                              Plu




Thursday, October 22, 2009
Why Test?

                     • Correctness
                     • Performance
                     • Knowing Your Code
                     • Documentation

Thursday, October 22, 2009
Cost of Change
                                    Development   Feature Testing          Regression Testing
                             Time




                                       v1.0       v2.0              v3.0             v4.0



Thursday, October 22, 2009
Feedback Loops

                                 Development



                                JIRA    Testing




Thursday, October 22, 2009
Feedback Loops
                                     Development




                              JIRA             Testing



Thursday, October 22, 2009
Development
                              Feedback Loops




                             JIRA                 Testing



Thursday, October 22, 2009
Cost of Change
                                    Development     Writing Tests          Executing Tests
                             Time




                                      v1.0        v2.0              v3.0           v4.0



Thursday, October 22, 2009
Eat Your Vegetables
Thursday, October 22, 2009
Variety



http://www.flickr.com/photos/sharontroy/3606495880/
Thursday, October 22, 2009
Ingredients Matter



http://www.flickr.com/photos/sharontroy/3938831210/
Thursday, October 22, 2009
Ingredients + Technique
                           = Art


http://www.flickr.com/photos/sharontroy/3606264108/
Thursday, October 22, 2009
No Regrets
http://www.redflagdeals.com/forums/costco-west-deals-dove-nailer-lays-tuna-gain-pantene-734644/
Thursday, October 22, 2009
Test-Driven Development
http://www.agiledata.org/essays/tdd.html
Thursday, October 22, 2009
Types of Tests
                             Unit              Integration




Thursday, October 22, 2009
Unit Tests




Thursday, October 22, 2009
What is Unit Testing?

                     • Tests individual components
                     • Avoids state & external systems
                     • Runs in development environment


Thursday, October 22, 2009
Why Unit Test?

                     • Correctness
                     • Improve Design
                     • Design by Contract


Thursday, October 22, 2009
How to Unit Test

                     • Set up
                     • Execute
                     • Verify
                     • Clean up

Thursday, October 22, 2009
How to Unit Test an Atlassian Plugin

Thursday, October 22, 2009
Unit Testing Tools




Thursday, October 22, 2009
JUnit

  public class UriTest {
    @Test
    public void absoluteUriParamIsReturned() {
      URI absoluteUri =
        URI.create("http://www.example.com");
      URI resolvedUri = resolveUriAgainstBase(
        "http://localhost:8080", absoluteUri)
      assertEquals(absoluteUri, resolvedUri);
    }
  }

Thursday, October 22, 2009
JUnit

  @Test(expected=
    GadgetSpecUriNotAllowedException.class)
  public void blankLocationThrowsException() {
    urlBuilder.parseGadgetSpecUrl(
      BASE_GADGET_SPEC_PATH
      + PLUGIN_KEY
      + "/"
      + "");
  }


Thursday, October 22, 2009
Mockito
  Dashboard dashboard = mock(Dashboard.class);
  DashboardStore store =
    mock(DashboardStore.class);
  when(dashboard.getId())
    .thenReturn(DASHBOARD_ID);
  when(store.update(dashboard))
    .thenReturn(DashboardStore.SUCCESS);

  repository.save(dashboard);

  verify(store)
    .update(DASHBOARD_ID, dashboard);
  verifyNoMoreInteractions(store);
Thursday, October 22, 2009
Hamcrest

  Iterable<ColumnIndex> range =
    ColumnIndex.range(ColumnIndex.ZERO,
                      ColumnIndex.ONE);
  Iterator<ColumnIndex> columnIt =
    range.iterator();
  assertThat(columnIt.next(),
             is(equalTo(ColumnIndex.ZERO)));
  assertThat(columnIt.next(),
             is(equalTo(ColumnIndex.ONE)));
  assertFalse(columnIt.hasNext());

Thursday, October 22, 2009
Hamcrest
  assertThat(iterator.next().getState(),
    is(sameInstance(gadget.getState())));

  assertThat(store.entries(),
    hasItem(GADGET_SPEC_URI));

  assertThat(staticContentTab.asText(),
    containsString("Static Content"));

  assertThat(changesList.get(1),
    is(deeplyEqualTo(
      new RemoveGadgetChange(gadgetId))));
Thursday, October 22, 2009
Clover




Thursday, October 22, 2009
Unit Testing Traps

                     • False Positives
                     • False Negatives
                     • Flapping


Thursday, October 22, 2009
Non-Test
                     • Doesn’t test what it appears to test
                     • No assertion
                     • Passes when code is broken
                     • Solutions:
                      • Test-Driven Development
                      • IDE inspections, PMD, FindBugs
Thursday, October 22, 2009
Missing Test
                     • Doesn’t test full range of inputs
                     • Boundary conditions, special cases
                     • Passes when code is broken
                     • Solutions:
                      • Clover
                      • JUnit Theories
Thursday, October 22, 2009
Coverage as a Crutch
                     • Over-reliance on Clover
                     • Misses code paths, boundary cases
                     • Passes when code is broken
                     • Solutions:
                      • Your brain
                      • Peer review
Thursday, October 22, 2009
Side-Effects
                     • Produces or relies on side-effects
                     • Maintains state between runs
                     • Fails inconsistently
                     • Solutions:
                      • Mock objects
                      • @Before/@After
Thursday, October 22, 2009
Over Constraint
                     • Tests implementation details
                     • Overuse of mocks
                     • Fails when code is not broken
                     • Solutions:
                      • Stubs/fakes
                      • Refactoring
Thursday, October 22, 2009
Unit Testing Traps

                     • False Positives   ←More tests
                     • False Negatives   ←Reduce coupling
                     • Flapping          ←Isolate


Thursday, October 22, 2009
Integration Tests




Thursday, October 22, 2009
What is Integration
                                 Testing?

                     • Tests full system
                     • Tests each supported configuration
                     • Runs in simulated production environment
                     • Many types: functional, load, stress, etc.

Thursday, October 22, 2009
Why Integration Test?

                     • Correctness
                     • Robustness
                     • Performance


Thursday, October 22, 2009
How to Integration Test

                     • Set up
                     • Execute
                     • Verify
                     • Clean up

Thursday, October 22, 2009
How to Integration Test
                      a Web Application
                     • Deploy your plugin or application
                     • Load data
                     • Simulate or script a web browser
                     • Parse the HTML to verify results
                     • Clean up

Thursday, October 22, 2009
How to Integration Test an
                                 Atlassian Plugin
Thursday, October 22, 2009
Integration Testing Tools




Thursday, October 22, 2009
JWebUnit

  beginAt("/home");
  clickLink("login");
  assertTitleEquals("Login");
  setTextField("username", "test");
  setTextField("password", "test123");
  submit();
  assertTitleEquals("Welcome, test!");



Thursday, October 22, 2009
HtmlUnit
  WebClient webClient = new WebClient();
  HtmlPage page =
    webClient.getPage("http://example.net");
  HtmlDivision div =
    page.getHtmlElementById("some_div_id");
  HtmlAnchor anchor =
    page.getAnchorByName("anchor_name");
  List<?> divs = page.getByXPath("//div");
  HtmlDivision div =
    page.getByXPath("//div[@name='John']")
        .get(0);

Thursday, October 22, 2009
JIRA/Confluence Test
                             Frameworks
  PageHelper helper = getPageHelper();

  helper.setSpaceKey(spaceKey);
  helper.setParentId(parentId);
  helper.setTitle(title);
  helper.setContent(content);
  helper.setCreationDate(new Date());
  helper.setLabels(labels);
  assertTrue(helper.create());


Thursday, October 22, 2009
JIRA/Confluence Test
                             Frameworks
  addUser("john.doe");
  addUserToGroup("john.doe", JIRA_DEV);
  activateTimeTracking();
  String issueKey =
    addIssue(TEST_PROJECT_NAME,
             TEST_PROJECT_KEY,
             "Bug", "First Bug", "Major", null,
             null, null, ADMIN_USERNAME, null,
             null, "1w", null, null);
  logWorkOnIssue(issueKey,"1d");
  gotoProjectBrowse(TEST_PROJECT_KEY);

Thursday, October 22, 2009
Atlassian Plugin SDK
                     $ atlas-unit-test
                     $ atlas-clover
                     $ atlas-integration-test
                             --version
                             --container
                             --product


Thursday, October 22, 2009
Selenium




Thursday, October 22, 2009
Integration Testing Traps

                     • False Positives
                     • False Negatives
                     • Flapping


Thursday, October 22, 2009
Incomplete
                     •       Doesn’t test the full system
                     •       JavaScript disabled, ignores browsers or app servers
                     •       Passes when code is broken
                     •       Solutions:
                             •   HtmlUnit
                             •   Selenium
                             •   Cargo
                             •   atlas-integration-test --container


Thursday, October 22, 2009
Entangled
                     •       Each test covers too much functionality
                     •       Requires lots of setup to test each feature
                     •       Bugs cause failures in tests for other features
                     •       Solutions:
                             •   Data loaders
                             •   Remote APIs
                             •   More specific test methods
                             •   Domain-driven test frameworks


Thursday, October 22, 2009
Fragile
                     • Tests break due to UI changes
                     • Screen-scraping, complicated XPath
                     • Fails when not broken
                     • Solutions:
                      • Semantic markup (class and id attributes)
                      • Domain-driven test frameworks
Thursday, October 22, 2009
Timing or State
                                   Dependencies
                     •       Inconsistent results from one test run to another
                     •       Concurrency bugs, no clean up, environment issues
                     •       Solutions:
                             •   @Before/@After
                             •   @BeforeClass/@AfterClass
                             •   Continuous Integration
                             •   Blood, sweat, and tears


Thursday, October 22, 2009
Slow
                     • Tests take too long to run
                     • Increases length of feedback loop
                     • Solutions:
                      • Clover test optimization
                      • Maven profiles
                      • Bamboo build trees
Thursday, October 22, 2009
Build Trees
                                         Clover-Optimized                 Faster


                                            Unit Tests

                             All Unit Tests              All Unit Tests
                                 Java 5                      Java 6       Slower



                            Integration                   Integration
                         Java 5/Tomcat 6               Java 6/Tomcat 6

           Integration               Integration   Integration    Integration
              Java 5                    Java 5        Java 6         Java 6
              JBoss                  Tomcat 5.5       JBoss       Tomcat 5.5
Thursday, October 22, 2009
Integration Testing Traps

                • False Positives   ←Test more
                • False Negatives   ←Framework
                • Flapping          ←Get to work


Thursday, October 22, 2009
Resources
                             http://j.mp/plugin-testing




Thursday, October 22, 2009

More Related Content

Similar to Plugin Testing

PHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An IntroductionPHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An Introductionalexmace
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And Techniques
Jordan Baker
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Peter Kofler
 
Scaling with Postgres
Scaling with PostgresScaling with Postgres
Scaling with Postgreselliando dias
 
Mozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMO
Matt Brandt
 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and Ecosystem
Ronald Bradford
 
Exceptable
ExceptableExceptable
Exceptable
Aurynn Shaw
 
Unit Testing Basics
Unit Testing BasicsUnit Testing Basics
Unit Testing Basics
Serhiy Oplakanets
 
Pitfalls of Continuous Deployment
Pitfalls of Continuous DeploymentPitfalls of Continuous Deployment
Pitfalls of Continuous Deployment
zeeg
 
Unit testing for Cocoa developers
Unit testing for Cocoa developersUnit testing for Cocoa developers
Unit testing for Cocoa developers
Graham Lee
 
Introtoduction to cocos2d
Introtoduction to  cocos2dIntrotoduction to  cocos2d
Introtoduction to cocos2d
John Wilker
 
iPhone Development Overview
iPhone Development OverviewiPhone Development Overview
iPhone Development Overview
Tom Adams
 
PRDC11-tdd-common-mistakes
PRDC11-tdd-common-mistakesPRDC11-tdd-common-mistakes
PRDC11-tdd-common-mistakes
Amir Barylko
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
Dante Briones
 
IT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged SoftwareIT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged Software
★ Selcuk Atli
 
Ruby On Rails Presentation Barcamp Antwerp.Key
Ruby On Rails Presentation Barcamp Antwerp.KeyRuby On Rails Presentation Barcamp Antwerp.Key
Ruby On Rails Presentation Barcamp Antwerp.KeyBert Goethals
 
mvcconf-bdd-quality-driven
mvcconf-bdd-quality-drivenmvcconf-bdd-quality-driven
mvcconf-bdd-quality-drivenAmir Barylko
 
Introduction to unit testing
Introduction to unit testingIntroduction to unit testing
Introduction to unit testingGil Zilberfeld
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
Andrey Oleynik
 

Similar to Plugin Testing (20)

PHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An IntroductionPHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An Introduction
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And Techniques
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
 
All The Little Pieces
All The Little PiecesAll The Little Pieces
All The Little Pieces
 
Scaling with Postgres
Scaling with PostgresScaling with Postgres
Scaling with Postgres
 
Mozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMO
 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and Ecosystem
 
Exceptable
ExceptableExceptable
Exceptable
 
Unit Testing Basics
Unit Testing BasicsUnit Testing Basics
Unit Testing Basics
 
Pitfalls of Continuous Deployment
Pitfalls of Continuous DeploymentPitfalls of Continuous Deployment
Pitfalls of Continuous Deployment
 
Unit testing for Cocoa developers
Unit testing for Cocoa developersUnit testing for Cocoa developers
Unit testing for Cocoa developers
 
Introtoduction to cocos2d
Introtoduction to  cocos2dIntrotoduction to  cocos2d
Introtoduction to cocos2d
 
iPhone Development Overview
iPhone Development OverviewiPhone Development Overview
iPhone Development Overview
 
PRDC11-tdd-common-mistakes
PRDC11-tdd-common-mistakesPRDC11-tdd-common-mistakes
PRDC11-tdd-common-mistakes
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
IT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged SoftwareIT Depends: Custom vs Packaged Software
IT Depends: Custom vs Packaged Software
 
Ruby On Rails Presentation Barcamp Antwerp.Key
Ruby On Rails Presentation Barcamp Antwerp.KeyRuby On Rails Presentation Barcamp Antwerp.Key
Ruby On Rails Presentation Barcamp Antwerp.Key
 
mvcconf-bdd-quality-driven
mvcconf-bdd-quality-drivenmvcconf-bdd-quality-driven
mvcconf-bdd-quality-driven
 
Introduction to unit testing
Introduction to unit testingIntroduction to unit testing
Introduction to unit testing
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 

Plugin Testing

  • 3. Plugin Testing her stuff gins & ot Plu Thursday, October 22, 2009
  • 4. Why Test? • Correctness • Performance • Knowing Your Code • Documentation Thursday, October 22, 2009
  • 5. Cost of Change Development Feature Testing Regression Testing Time v1.0 v2.0 v3.0 v4.0 Thursday, October 22, 2009
  • 6. Feedback Loops Development JIRA Testing Thursday, October 22, 2009
  • 7. Feedback Loops Development JIRA Testing Thursday, October 22, 2009
  • 8. Development Feedback Loops JIRA Testing Thursday, October 22, 2009
  • 9. Cost of Change Development Writing Tests Executing Tests Time v1.0 v2.0 v3.0 v4.0 Thursday, October 22, 2009
  • 10. Eat Your Vegetables Thursday, October 22, 2009
  • 13. Ingredients + Technique = Art http://www.flickr.com/photos/sharontroy/3606264108/ Thursday, October 22, 2009
  • 16. Types of Tests Unit Integration Thursday, October 22, 2009
  • 18. What is Unit Testing? • Tests individual components • Avoids state & external systems • Runs in development environment Thursday, October 22, 2009
  • 19. Why Unit Test? • Correctness • Improve Design • Design by Contract Thursday, October 22, 2009
  • 20. How to Unit Test • Set up • Execute • Verify • Clean up Thursday, October 22, 2009
  • 21. How to Unit Test an Atlassian Plugin Thursday, October 22, 2009
  • 22. Unit Testing Tools Thursday, October 22, 2009
  • 23. JUnit public class UriTest { @Test public void absoluteUriParamIsReturned() { URI absoluteUri = URI.create("http://www.example.com"); URI resolvedUri = resolveUriAgainstBase( "http://localhost:8080", absoluteUri) assertEquals(absoluteUri, resolvedUri); } } Thursday, October 22, 2009
  • 24. JUnit @Test(expected= GadgetSpecUriNotAllowedException.class) public void blankLocationThrowsException() { urlBuilder.parseGadgetSpecUrl( BASE_GADGET_SPEC_PATH + PLUGIN_KEY + "/" + ""); } Thursday, October 22, 2009
  • 25. Mockito Dashboard dashboard = mock(Dashboard.class); DashboardStore store = mock(DashboardStore.class); when(dashboard.getId()) .thenReturn(DASHBOARD_ID); when(store.update(dashboard)) .thenReturn(DashboardStore.SUCCESS); repository.save(dashboard); verify(store) .update(DASHBOARD_ID, dashboard); verifyNoMoreInteractions(store); Thursday, October 22, 2009
  • 26. Hamcrest Iterable<ColumnIndex> range = ColumnIndex.range(ColumnIndex.ZERO, ColumnIndex.ONE); Iterator<ColumnIndex> columnIt = range.iterator(); assertThat(columnIt.next(), is(equalTo(ColumnIndex.ZERO))); assertThat(columnIt.next(), is(equalTo(ColumnIndex.ONE))); assertFalse(columnIt.hasNext()); Thursday, October 22, 2009
  • 27. Hamcrest assertThat(iterator.next().getState(), is(sameInstance(gadget.getState()))); assertThat(store.entries(), hasItem(GADGET_SPEC_URI)); assertThat(staticContentTab.asText(), containsString("Static Content")); assertThat(changesList.get(1), is(deeplyEqualTo( new RemoveGadgetChange(gadgetId)))); Thursday, October 22, 2009
  • 29. Unit Testing Traps • False Positives • False Negatives • Flapping Thursday, October 22, 2009
  • 30. Non-Test • Doesn’t test what it appears to test • No assertion • Passes when code is broken • Solutions: • Test-Driven Development • IDE inspections, PMD, FindBugs Thursday, October 22, 2009
  • 31. Missing Test • Doesn’t test full range of inputs • Boundary conditions, special cases • Passes when code is broken • Solutions: • Clover • JUnit Theories Thursday, October 22, 2009
  • 32. Coverage as a Crutch • Over-reliance on Clover • Misses code paths, boundary cases • Passes when code is broken • Solutions: • Your brain • Peer review Thursday, October 22, 2009
  • 33. Side-Effects • Produces or relies on side-effects • Maintains state between runs • Fails inconsistently • Solutions: • Mock objects • @Before/@After Thursday, October 22, 2009
  • 34. Over Constraint • Tests implementation details • Overuse of mocks • Fails when code is not broken • Solutions: • Stubs/fakes • Refactoring Thursday, October 22, 2009
  • 35. Unit Testing Traps • False Positives ←More tests • False Negatives ←Reduce coupling • Flapping ←Isolate Thursday, October 22, 2009
  • 37. What is Integration Testing? • Tests full system • Tests each supported configuration • Runs in simulated production environment • Many types: functional, load, stress, etc. Thursday, October 22, 2009
  • 38. Why Integration Test? • Correctness • Robustness • Performance Thursday, October 22, 2009
  • 39. How to Integration Test • Set up • Execute • Verify • Clean up Thursday, October 22, 2009
  • 40. How to Integration Test a Web Application • Deploy your plugin or application • Load data • Simulate or script a web browser • Parse the HTML to verify results • Clean up Thursday, October 22, 2009
  • 41. How to Integration Test an Atlassian Plugin Thursday, October 22, 2009
  • 43. JWebUnit beginAt("/home"); clickLink("login"); assertTitleEquals("Login"); setTextField("username", "test"); setTextField("password", "test123"); submit(); assertTitleEquals("Welcome, test!"); Thursday, October 22, 2009
  • 44. HtmlUnit WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage("http://example.net"); HtmlDivision div = page.getHtmlElementById("some_div_id"); HtmlAnchor anchor = page.getAnchorByName("anchor_name"); List<?> divs = page.getByXPath("//div"); HtmlDivision div = page.getByXPath("//div[@name='John']") .get(0); Thursday, October 22, 2009
  • 45. JIRA/Confluence Test Frameworks PageHelper helper = getPageHelper(); helper.setSpaceKey(spaceKey); helper.setParentId(parentId); helper.setTitle(title); helper.setContent(content); helper.setCreationDate(new Date()); helper.setLabels(labels); assertTrue(helper.create()); Thursday, October 22, 2009
  • 46. JIRA/Confluence Test Frameworks addUser("john.doe"); addUserToGroup("john.doe", JIRA_DEV); activateTimeTracking(); String issueKey = addIssue(TEST_PROJECT_NAME, TEST_PROJECT_KEY, "Bug", "First Bug", "Major", null, null, null, ADMIN_USERNAME, null, null, "1w", null, null); logWorkOnIssue(issueKey,"1d"); gotoProjectBrowse(TEST_PROJECT_KEY); Thursday, October 22, 2009
  • 47. Atlassian Plugin SDK $ atlas-unit-test $ atlas-clover $ atlas-integration-test --version --container --product Thursday, October 22, 2009
  • 49. Integration Testing Traps • False Positives • False Negatives • Flapping Thursday, October 22, 2009
  • 50. Incomplete • Doesn’t test the full system • JavaScript disabled, ignores browsers or app servers • Passes when code is broken • Solutions: • HtmlUnit • Selenium • Cargo • atlas-integration-test --container Thursday, October 22, 2009
  • 51. Entangled • Each test covers too much functionality • Requires lots of setup to test each feature • Bugs cause failures in tests for other features • Solutions: • Data loaders • Remote APIs • More specific test methods • Domain-driven test frameworks Thursday, October 22, 2009
  • 52. Fragile • Tests break due to UI changes • Screen-scraping, complicated XPath • Fails when not broken • Solutions: • Semantic markup (class and id attributes) • Domain-driven test frameworks Thursday, October 22, 2009
  • 53. Timing or State Dependencies • Inconsistent results from one test run to another • Concurrency bugs, no clean up, environment issues • Solutions: • @Before/@After • @BeforeClass/@AfterClass • Continuous Integration • Blood, sweat, and tears Thursday, October 22, 2009
  • 54. Slow • Tests take too long to run • Increases length of feedback loop • Solutions: • Clover test optimization • Maven profiles • Bamboo build trees Thursday, October 22, 2009
  • 55. Build Trees Clover-Optimized Faster Unit Tests All Unit Tests All Unit Tests Java 5 Java 6 Slower Integration Integration Java 5/Tomcat 6 Java 6/Tomcat 6 Integration Integration Integration Integration Java 5 Java 5 Java 6 Java 6 JBoss Tomcat 5.5 JBoss Tomcat 5.5 Thursday, October 22, 2009
  • 56. Integration Testing Traps • False Positives ←Test more • False Negatives ←Framework • Flapping ←Get to work Thursday, October 22, 2009
  • 57. Resources http://j.mp/plugin-testing Thursday, October 22, 2009