SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
New types of tests for
Java projects
Vincent Massol, January 2020
Agenda
•Context
•Backward compatibility testing
•Coverage testing
•Mutation testing
•Configuration testing
•Crash reproduction
Context: XWiki
• Open source wiki
• 15 years
• 10-15 active committers
• Very extensible, scripting in wiki pages
• Platform for developing ad-hoc web applications
• Strong build practices using Maven and lots of “Quality” plugins
• Using Jenkins & custom pipeline library for the CI
https://xwiki.org
Context: STAMP
• Automatic Test Amplification
• XWiki SAS participating, 3 years
• Experiments on XWiki project
Mutation testing Environment Testing Production Testing
Testing Status (after STAMP)
• 11074 automated tests (in 2.7 hours):
• Unit tests (using JUnit5 & Mockito)
• Functional (UI) tests (using Selenium/Webdriver) and using
Docker
Data from 31 Jan 2020
New questions
• How can I prevent breaking my users (when I
expose some APIs)? Backward compatibility
• Are my tests testing enough? Coverage
• How good are my tests? Mutation testing
• Do my software work in various setups?
Configuration testing
• How can I reproduce bugs found in production?
Production testing
= in place w/ strategy = in progress
Backward Compatibility
Backward Compatibility
• For APIs (and SPIs)
• Using the Revapi Maven plugin
• Supports source and binary compatibility
• Strategy:
• Break the build on backward compatibility
violations
• Add ignores in pom.xml if really needed
and ok
• Add ignore list in release notes to warn
users of your APIs
Backward Compatibility
• Strategy continued:
• Use @Deprecated annotation
• Once no more code uses deprecated API, move it to Legacy
module.We don’t break backward compatibility!
• Use AspectJ in Legacy module to generate and aspectified
API (JAR)
• Makes code clean and not able to use the Legacy modules
(build-enforced)
• Distribute the legacy modules
public privileged aspect ApiCompatibilityAspect
{
@Deprecated
public boolean Api.checkProgrammingRights()
{
return this.hasProgrammingRights();
}
}
Java 8 default methods helped a lot
Backward Compatibility
• Strategy continued:
• For young APIs, use @Unstable + @Since
• Enforced by build (to make sure @Since is there).
Custom checkstyle rule (or Spoon rule)
• Max duration is one cycle (i.e. 1 year).
• Enforced by build (fails the build if beyond).
/**
* ...
* @since 9.7RC1
*/
@Unstable
public List<MacroDescriptor> getMacroDescriptors(Syntax syntax) throws MacroLookupException
{
...
}
Mention that as a result XWiki
extensions and scripts can still run in
XWiki even several years after they
were released.
Coverage
Test Coverage - Local
• Using Jacoco and Clover
• Strategy - “Ratchet effect”:
• Each Maven module has a threshold
• Jacoco Maven plugin fails if new code has less coverage than
before in %
• Devs are allowed to increase threshold
Of course TPC is not panacea. You
could have 100% and app not
working. Also need functional tests.
Aim for 80%.
Test Coverage - Global
• Issue: Local coverage can increase and
global decrease
• Removed code with high TPC
• Code tested indirectly by functional
tests and code refactoring led to
different paths used
• New module with lower TPC than
average
Global TPC evolution
Test Coverage - Global
• Strategy:
• Global Clover TPC computed automatically every night on
Jenkins for all repos combined, using a pipeline
• Email sent to developers with report in email (see next slide)
• But only when global TPC is reduced
• Developers fix module they have been working on
• Release Manager (RM) ensures that report passes before
release & we add one step in our Release Plan check list.
Source: http://massol.myxwiki.org/xwiki/bin/view/Blog/ComparingCloverReports
Test Coverage - Global
Mutation Testing
Mutation Testing
• Using PIT/Gregor, PIT/Descartes
• Concepts of PIT
• Modify code under test (mutants) and run tests
• Good tests kill mutants
• Generates a mutation score similar to the coverage %
• Descartes = extreme mutations that execute fast and have high
values
https://massol.myxwiki.org/xwiki/bin/view/Blog/MutationTestingDescartes
Mutation - Issue Report
Mutation - Example
Mutation - Example
result =
   (getId() == macroId.getId() || (getId() != null && getId().equals(macroId.getId())))
   && (getSyntax() == macroId.getSyntax() || (getSyntax() != null && getSyntax().equals(
    macroId.getSyntax())));
Mutation - Example
@Test
public void testEquality()
{
    MacroId id1 = new MacroId("id", Syntax.XWIKI_2_0);
    MacroId id2 = new MacroId("id", Syntax.XWIKI_2_0);
    MacroId id3 = new MacroId("otherid", Syntax.XWIKI_2_0);
    MacroId id4 = new MacroId("id", Syntax.XHTML_1_0);
    MacroId id5 = new MacroId("otherid", Syntax.XHTML_1_0);
    MacroId id6 = new MacroId("id");
    MacroId id7 = new MacroId("id");
    Assert.assertEquals(id2, id1);
   // Equal objects must have equal hashcode
   Assert.assertTrue(id1.hashCode() == id2.hashCode());
    Assert.assertFalse(id3 == id1);
    Assert.assertFalse(id4 == id1);
    Assert.assertFalse(id5 == id3);
    Assert.assertFalse(id6 == id1);
    Assert.assertEquals(id7, id6);
   // Equal objects must have equal hashcode
   Assert.assertTrue(id6.hashCode() == id7.hashCode());
}
Not testing
for inequality!
Improved thanks to Descartes!
Mutation - Strategy
• Been in place for 1 year now
• Fail the build when the mutation score of a given module is below
a defined threshold in the pom.xml
• The idea is that new tests should, in average, be of quality equal or
better than past tests.
• Other idea: hook on CI to run it only on modified code/tests.
General goal with coverage + mutation: maintain quality
Mutation - Limitations
• A bit slow, by definition
• 2h30 on xwiki
• Executed in scheduled jobs (once per day)
• PITmp Maven plugin to execute on multi-module
• All sources mutated, not just sources where tests are
• Much slower as a consequence, and thus difficult to
generate a global mutation score
Mutation: Going further
• Using DSpot
• Uses PIT/Descartes but injects
results to generate new tests
• Adds assertions to existing tests
• Generate new test methods
• Selector can be PIT/Gregor, PIT/
Descartes, Jacoco (instruction
coverage), Clover (Branch
coverage)
https://massol.myxwiki.org/xwiki/bin/view/Blog/TestGenerationDspot
Mutation: Dspot Example 1
public void escapeAttributeValue2() {
String escapedText = XMLUtils.escapeAttributeValue("a < a' && a' < a" => a < a" {");
// AssertGenerator add assertion
Assert.assertEquals("a &#60; a&#39; &#38;&#38; a&#39; &#60; a&#34; =&#62; a &#60; a&#34; &#123;", escapedText);
// AssertGenerator create local variable with return value of invocation
boolean o_escapeAttributeValue__3 = escapedText.contains("<");
// AssertGenerator add assertion
Assert.assertFalse(o_escapeAttributeValue__3);
// AssertGenerator create local variable with return value of invocation
boolean o_escapeAttributeValue__4 = escapedText.contains(">");
// AssertGenerator add assertion
Assert.assertFalse(o_escapeAttributeValue__4);
// AssertGenerator create local variable with return value of invocation
boolean o_escapeAttributeValue__5 = escapedText.contains("'");
// AssertGenerator add assertion
Assert.assertFalse(o_escapeAttributeValue__5);
// AssertGenerator create local variable with return value of invocation
boolean o_escapeAttributeValue__6 = escapedText.contains(""");
// AssertGenerator create local variable with return value of invocation
boolean o_escapeAttributeValue__7 = escapedText.contains("&&");
// AssertGenerator add assertion
Assert.assertFalse(o_escapeAttributeValue__7);
// AssertGenerator create local variable with return value of invocation
boolean o_escapeAttributeValue__8 = escapedText.contains("{");
// AssertGenerator add assertion
Assert.assertFalse(o_escapeAttributeValue__8);
}
Generated test
New test
@Test
public void escapeAttributeValue()
{
String escapedText = XMLUtils.escapeAttributeValue("a < a' && a' < a" => a < a" {");
assertFalse("Failed to escape <", escapedText.contains("<"));
assertFalse("Failed to escape >", escapedText.contains(">"));
assertFalse("Failed to escape '", escapedText.contains("'"));
assertFalse("Failed to escape "", escapedText.contains("""));
assertFalse("Failed to escape &", escapedText.contains("&&"));
assertFalse("Failed to escape {", escapedText.contains("{"));
}
Original test
Mutation: Dspot Example 2
Generated test
Original test
Also increase coverage
Before: 70.5%
After: 71.2%
Mutation: Dspot Strategy
• DSpot is very slow to execute (between 3 to 20mn on
small modules)
• One strategy is to run it on CI and in the pipeline commit
generated tests in a different source root.
• And run it only on Tests affected by commit changeset
• Configure Maven to add a new test directory source using
the Maven Build Helper plugin.
• Work in progress: small coverage and mutation score
improvements on XWiki so far.
Configuration Testing
Environment Testing
• Environment = combination of Servlet
container & version, DB & version, OS,
Browser & version
• And also cluster mode, LibreOffice
integration, external SOLR, etc
• Need: Be able to run/debug functional
tests on local dev machines as well as on
CI
• Using Docker / TestContainers
Environment Testing
https://massol.myxwiki.org/xwiki/bin/view/Blog/EnvironmentTestingExperimentations
Environment Testing
Environment Testing
• Feedback: takes about 3 minutes to deploy all (and 1 minute for the
test)
• Strategy
• Run on CI (Jenkins)
• As part of the main pipeline but using the parametrised
scheduler plugin
• 3 jobs
• “latest”: latest version, executes daily
• “all”: all supported configs, executed weekly
• “unsupported”: all currently unsupported configs, executed
monthly
Crash Reproduction
Crash Reproduction
• Tool: EvoCrash / Botsing
• Concept:Take a stack trace
and generates a test that,
when executed, leads to this
stack trace
• i.e. find the conditions that
leads to the problem
EvoCrash Example
10 frames reproduced!
Evocrash - Feedback
• Can take a long time to reproduce, doesn’t always succeed
• Generates a test that reproduces the problem, not the fix!
• Often you’d write a test at a different level (usually up in the call
chain, to be more meaningful to the use case)
• Is useful for newcomers who don’t know the codebase well as it
helps pinpoint the problem. Acts as a timesaver.
Parting words
• Experiment, push the limit!
• Some other types of tests not covered and that also need
automation
• Performance/Stress testing
• Usability testing
• others?
• Functional UI tests and Config tests are hard because of flickers and
the required environment stability
Q&A
Me
Vincent Massol
vincent@massol.net
skype: vmassol
http://about.me/vmassol
http://xwiki.org
http://xwiki.com

Mais conteúdo relacionado

Mais procurados

Life-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTestLife-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTestElasTest Project
 
TDC2016SP - Trilha Embarcados
TDC2016SP - Trilha EmbarcadosTDC2016SP - Trilha Embarcados
TDC2016SP - Trilha Embarcadostdc-globalcode
 
Develop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConfDevelop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConfAnnyce Davis
 
Continuous integration at scale
Continuous integration at scaleContinuous integration at scale
Continuous integration at scaleVivek Singh
 
Test Management System (TMS) using JIRA Customization
Test Management System (TMS) using JIRA CustomizationTest Management System (TMS) using JIRA Customization
Test Management System (TMS) using JIRA CustomizationYagnanarayana Dande
 
Continuous Delivery Applied (AgileDC)
Continuous Delivery Applied (AgileDC)Continuous Delivery Applied (AgileDC)
Continuous Delivery Applied (AgileDC)Mike McGarr
 
Cpp Testing Techniques Tips and Tricks - Cpp Europe
Cpp Testing Techniques Tips and Tricks - Cpp EuropeCpp Testing Techniques Tips and Tricks - Cpp Europe
Cpp Testing Techniques Tips and Tricks - Cpp EuropeClare Macrae
 
2016 04-25 continuous integration at google scale
2016 04-25 continuous integration at google scale2016 04-25 continuous integration at google scale
2016 04-25 continuous integration at google scaleJohn Micco
 
In defense of GWT-RPC By Colin Alworth
In defense of GWT-RPC By Colin AlworthIn defense of GWT-RPC By Colin Alworth
In defense of GWT-RPC By Colin AlworthGWTcon
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous IntegrationKelli Mohr
 
TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]Clive Dall
 
Achieving Full Stack DevOps at Colonial Life
Achieving Full Stack DevOps at Colonial Life Achieving Full Stack DevOps at Colonial Life
Achieving Full Stack DevOps at Colonial Life DevOps.com
 
A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...
A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...
A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...Yuval Yeret
 
Dot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarDot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarGiel Tettelaar
 
How to Upgrade to the Newest Shiniest Django Version
How to Upgrade to the Newest Shiniest Django VersionHow to Upgrade to the Newest Shiniest Django Version
How to Upgrade to the Newest Shiniest Django VersionSusan Tan
 
QA methodology by Quality Tech
QA methodology  by Quality TechQA methodology  by Quality Tech
QA methodology by Quality TechIvet Prokopova
 
How do you implement Continuous Delivery? Part 3: All about Pipelines
How do you implement Continuous Delivery? Part 3: All about PipelinesHow do you implement Continuous Delivery? Part 3: All about Pipelines
How do you implement Continuous Delivery? Part 3: All about PipelinesThoughtworks
 

Mais procurados (20)

ElasTest Webinar
ElasTest WebinarElasTest Webinar
ElasTest Webinar
 
Life-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTestLife-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTest
 
Manual estimation approach for Pre-sale phase of a project
Manual estimation approach for Pre-sale phase of a projectManual estimation approach for Pre-sale phase of a project
Manual estimation approach for Pre-sale phase of a project
 
TDC2016SP - Trilha Embarcados
TDC2016SP - Trilha EmbarcadosTDC2016SP - Trilha Embarcados
TDC2016SP - Trilha Embarcados
 
Develop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConfDevelop Maintainable Apps - edUiConf
Develop Maintainable Apps - edUiConf
 
Continuous integration at scale
Continuous integration at scaleContinuous integration at scale
Continuous integration at scale
 
Test Management System (TMS) using JIRA Customization
Test Management System (TMS) using JIRA CustomizationTest Management System (TMS) using JIRA Customization
Test Management System (TMS) using JIRA Customization
 
Continuous Delivery Applied (AgileDC)
Continuous Delivery Applied (AgileDC)Continuous Delivery Applied (AgileDC)
Continuous Delivery Applied (AgileDC)
 
Cpp Testing Techniques Tips and Tricks - Cpp Europe
Cpp Testing Techniques Tips and Tricks - Cpp EuropeCpp Testing Techniques Tips and Tricks - Cpp Europe
Cpp Testing Techniques Tips and Tricks - Cpp Europe
 
2016 04-25 continuous integration at google scale
2016 04-25 continuous integration at google scale2016 04-25 continuous integration at google scale
2016 04-25 continuous integration at google scale
 
In defense of GWT-RPC By Colin Alworth
In defense of GWT-RPC By Colin AlworthIn defense of GWT-RPC By Colin Alworth
In defense of GWT-RPC By Colin Alworth
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]TEST_AUTOMATION_CASE_STUDY_(2)2[1]
TEST_AUTOMATION_CASE_STUDY_(2)2[1]
 
Achieving Full Stack DevOps at Colonial Life
Achieving Full Stack DevOps at Colonial Life Achieving Full Stack DevOps at Colonial Life
Achieving Full Stack DevOps at Colonial Life
 
A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...
A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...
A Software Tester's Travels from the Land of the Waterfall to the Land of Agi...
 
Dot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel TettelarDot all 2019 | Testing with Craft | Giel Tettelar
Dot all 2019 | Testing with Craft | Giel Tettelar
 
How to Upgrade to the Newest Shiniest Django Version
How to Upgrade to the Newest Shiniest Django VersionHow to Upgrade to the Newest Shiniest Django Version
How to Upgrade to the Newest Shiniest Django Version
 
Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
QA methodology by Quality Tech
QA methodology  by Quality TechQA methodology  by Quality Tech
QA methodology by Quality Tech
 
How do you implement Continuous Delivery? Part 3: All about Pipelines
How do you implement Continuous Delivery? Part 3: All about PipelinesHow do you implement Continuous Delivery? Part 3: All about Pipelines
How do you implement Continuous Delivery? Part 3: All about Pipelines
 

Semelhante a New types of tests for Java projects

Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019Vincent Massol
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projectsVincent Massol
 
Implementing Quality on a Java Project
Implementing Quality on a Java ProjectImplementing Quality on a Java Project
Implementing Quality on a Java ProjectVincent Massol
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersVMware Tanzu
 
XWiki SAS development practices
XWiki SAS development practicesXWiki SAS development practices
XWiki SAS development practicesVincent Massol
 
Improve unit tests with Mutants!
Improve unit tests with Mutants!Improve unit tests with Mutants!
Improve unit tests with Mutants!Paco van Beckhoven
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)CIVEL Benoit
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1CIVEL Benoit
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherencearagozin
 
XWiki Testing with TestContainers
XWiki Testing with TestContainersXWiki Testing with TestContainers
XWiki Testing with TestContainersVincent Massol
 
Mutation testing Bucharest Tech Week
Mutation testing Bucharest Tech WeekMutation testing Bucharest Tech Week
Mutation testing Bucharest Tech WeekPaco van Beckhoven
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017XavierDevroey
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
Test parallelization using Jenkins
Test parallelization using JenkinsTest parallelization using Jenkins
Test parallelization using JenkinsRogue Wave Software
 
Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Scott Keck-Warren
 

Semelhante a New types of tests for Java projects (20)

Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projects
 
Advanced Java Testing
Advanced Java TestingAdvanced Java Testing
Advanced Java Testing
 
Building XWiki
Building XWikiBuilding XWiki
Building XWiki
 
Implementing Quality on a Java Project
Implementing Quality on a Java ProjectImplementing Quality on a Java Project
Implementing Quality on a Java Project
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
 
XWiki SAS development practices
XWiki SAS development practicesXWiki SAS development practices
XWiki SAS development practices
 
Improve unit tests with Mutants!
Improve unit tests with Mutants!Improve unit tests with Mutants!
Improve unit tests with Mutants!
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 
XWiki Testing with TestContainers
XWiki Testing with TestContainersXWiki Testing with TestContainers
XWiki Testing with TestContainers
 
Mutation testing Bucharest Tech Week
Mutation testing Bucharest Tech WeekMutation testing Bucharest Tech Week
Mutation testing Bucharest Tech Week
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
Mini training - Moving to xUnit.net
Mini training - Moving to xUnit.netMini training - Moving to xUnit.net
Mini training - Moving to xUnit.net
 
Test parallelization using Jenkins
Test parallelization using JenkinsTest parallelization using Jenkins
Test parallelization using Jenkins
 
Developing XWiki
Developing XWikiDeveloping XWiki
Developing XWiki
 
Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023
 

Mais de Vincent Massol

XWiki: The best wiki for developers
XWiki: The best wiki for developersXWiki: The best wiki for developers
XWiki: The best wiki for developersVincent Massol
 
Configuration Testing with Docker & TestContainers
Configuration Testing with Docker & TestContainersConfiguration Testing with Docker & TestContainers
Configuration Testing with Docker & TestContainersVincent Massol
 
What's new in XWiki 9.x and 10.x
What's new in XWiki 9.x and 10.xWhat's new in XWiki 9.x and 10.x
What's new in XWiki 9.x and 10.xVincent Massol
 
Creating your own project's Quality Dashboard
Creating your own project's Quality DashboardCreating your own project's Quality Dashboard
Creating your own project's Quality DashboardVincent Massol
 
XWiki: wiki collaboration as an alternative to Confluence and Sharepoint
XWiki: wiki collaboration as an alternative to Confluence and SharepointXWiki: wiki collaboration as an alternative to Confluence and Sharepoint
XWiki: wiki collaboration as an alternative to Confluence and SharepointVincent Massol
 
Creating your own project's Quality Dashboard
Creating your own project's Quality DashboardCreating your own project's Quality Dashboard
Creating your own project's Quality DashboardVincent Massol
 
XWiki: The web's Swiss Army Knife
XWiki: The web's Swiss Army KnifeXWiki: The web's Swiss Army Knife
XWiki: The web's Swiss Army KnifeVincent Massol
 
Leading a Community-Driven Open Source Project
Leading a Community-Driven Open Source ProjectLeading a Community-Driven Open Source Project
Leading a Community-Driven Open Source ProjectVincent Massol
 
XWiki Status - July 2015
XWiki Status - July 2015XWiki Status - July 2015
XWiki Status - July 2015Vincent Massol
 
XWiki SAS: An open source company
XWiki SAS: An open source companyXWiki SAS: An open source company
XWiki SAS: An open source companyVincent Massol
 
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014Vincent Massol
 
XWiki Rendering @ FOSDEM 2014
XWiki Rendering @ FOSDEM 2014XWiki Rendering @ FOSDEM 2014
XWiki Rendering @ FOSDEM 2014Vincent Massol
 
Implementing Quality on Java projects (Short version)
Implementing Quality on Java projects (Short version)Implementing Quality on Java projects (Short version)
Implementing Quality on Java projects (Short version)Vincent Massol
 
Implementing quality in Java projects
Implementing quality in Java projectsImplementing quality in Java projects
Implementing quality in Java projectsVincent Massol
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projectsVincent Massol
 
Combining open source ethics with private interests
Combining open source ethics with private interestsCombining open source ethics with private interests
Combining open source ethics with private interestsVincent Massol
 
Evolutions XWiki 2012/2013
Evolutions XWiki 2012/2013Evolutions XWiki 2012/2013
Evolutions XWiki 2012/2013Vincent Massol
 
XWiki: Developing simple apps quickly
XWiki: Developing simple apps quicklyXWiki: Developing simple apps quickly
XWiki: Developing simple apps quicklyVincent Massol
 
XWiki: Building a dynamic Conference web site
XWiki: Building a dynamic Conference web siteXWiki: Building a dynamic Conference web site
XWiki: Building a dynamic Conference web siteVincent Massol
 

Mais de Vincent Massol (20)

XWiki: The best wiki for developers
XWiki: The best wiki for developersXWiki: The best wiki for developers
XWiki: The best wiki for developers
 
Configuration Testing with Docker & TestContainers
Configuration Testing with Docker & TestContainersConfiguration Testing with Docker & TestContainers
Configuration Testing with Docker & TestContainers
 
What's new in XWiki 9.x and 10.x
What's new in XWiki 9.x and 10.xWhat's new in XWiki 9.x and 10.x
What's new in XWiki 9.x and 10.x
 
Creating your own project's Quality Dashboard
Creating your own project's Quality DashboardCreating your own project's Quality Dashboard
Creating your own project's Quality Dashboard
 
XWiki: wiki collaboration as an alternative to Confluence and Sharepoint
XWiki: wiki collaboration as an alternative to Confluence and SharepointXWiki: wiki collaboration as an alternative to Confluence and Sharepoint
XWiki: wiki collaboration as an alternative to Confluence and Sharepoint
 
Creating your own project's Quality Dashboard
Creating your own project's Quality DashboardCreating your own project's Quality Dashboard
Creating your own project's Quality Dashboard
 
XWiki: The web's Swiss Army Knife
XWiki: The web's Swiss Army KnifeXWiki: The web's Swiss Army Knife
XWiki: The web's Swiss Army Knife
 
Leading a Community-Driven Open Source Project
Leading a Community-Driven Open Source ProjectLeading a Community-Driven Open Source Project
Leading a Community-Driven Open Source Project
 
XWiki Status - July 2015
XWiki Status - July 2015XWiki Status - July 2015
XWiki Status - July 2015
 
XWiki SAS: An open source company
XWiki SAS: An open source companyXWiki SAS: An open source company
XWiki SAS: An open source company
 
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
XWiki: A web dev runtime for writing web apps @ FOSDEM 2014
 
XWiki Rendering @ FOSDEM 2014
XWiki Rendering @ FOSDEM 2014XWiki Rendering @ FOSDEM 2014
XWiki Rendering @ FOSDEM 2014
 
Implementing Quality on Java projects (Short version)
Implementing Quality on Java projects (Short version)Implementing Quality on Java projects (Short version)
Implementing Quality on Java projects (Short version)
 
Implementing quality in Java projects
Implementing quality in Java projectsImplementing quality in Java projects
Implementing quality in Java projects
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projects
 
Combining open source ethics with private interests
Combining open source ethics with private interestsCombining open source ethics with private interests
Combining open source ethics with private interests
 
Evolutions XWiki 2012/2013
Evolutions XWiki 2012/2013Evolutions XWiki 2012/2013
Evolutions XWiki 2012/2013
 
Developing XWiki
Developing XWikiDeveloping XWiki
Developing XWiki
 
XWiki: Developing simple apps quickly
XWiki: Developing simple apps quicklyXWiki: Developing simple apps quickly
XWiki: Developing simple apps quickly
 
XWiki: Building a dynamic Conference web site
XWiki: Building a dynamic Conference web siteXWiki: Building a dynamic Conference web site
XWiki: Building a dynamic Conference web site
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

New types of tests for Java projects

  • 1. New types of tests for Java projects Vincent Massol, January 2020
  • 2. Agenda •Context •Backward compatibility testing •Coverage testing •Mutation testing •Configuration testing •Crash reproduction
  • 3. Context: XWiki • Open source wiki • 15 years • 10-15 active committers • Very extensible, scripting in wiki pages • Platform for developing ad-hoc web applications • Strong build practices using Maven and lots of “Quality” plugins • Using Jenkins & custom pipeline library for the CI https://xwiki.org
  • 4. Context: STAMP • Automatic Test Amplification • XWiki SAS participating, 3 years • Experiments on XWiki project Mutation testing Environment Testing Production Testing
  • 5. Testing Status (after STAMP) • 11074 automated tests (in 2.7 hours): • Unit tests (using JUnit5 & Mockito) • Functional (UI) tests (using Selenium/Webdriver) and using Docker Data from 31 Jan 2020
  • 6. New questions • How can I prevent breaking my users (when I expose some APIs)? Backward compatibility • Are my tests testing enough? Coverage • How good are my tests? Mutation testing • Do my software work in various setups? Configuration testing • How can I reproduce bugs found in production? Production testing = in place w/ strategy = in progress
  • 8. Backward Compatibility • For APIs (and SPIs) • Using the Revapi Maven plugin • Supports source and binary compatibility • Strategy: • Break the build on backward compatibility violations • Add ignores in pom.xml if really needed and ok • Add ignore list in release notes to warn users of your APIs
  • 9. Backward Compatibility • Strategy continued: • Use @Deprecated annotation • Once no more code uses deprecated API, move it to Legacy module.We don’t break backward compatibility! • Use AspectJ in Legacy module to generate and aspectified API (JAR) • Makes code clean and not able to use the Legacy modules (build-enforced) • Distribute the legacy modules public privileged aspect ApiCompatibilityAspect { @Deprecated public boolean Api.checkProgrammingRights() { return this.hasProgrammingRights(); } } Java 8 default methods helped a lot
  • 10. Backward Compatibility • Strategy continued: • For young APIs, use @Unstable + @Since • Enforced by build (to make sure @Since is there). Custom checkstyle rule (or Spoon rule) • Max duration is one cycle (i.e. 1 year). • Enforced by build (fails the build if beyond). /** * ... * @since 9.7RC1 */ @Unstable public List<MacroDescriptor> getMacroDescriptors(Syntax syntax) throws MacroLookupException { ... } Mention that as a result XWiki extensions and scripts can still run in XWiki even several years after they were released.
  • 12. Test Coverage - Local • Using Jacoco and Clover • Strategy - “Ratchet effect”: • Each Maven module has a threshold • Jacoco Maven plugin fails if new code has less coverage than before in % • Devs are allowed to increase threshold Of course TPC is not panacea. You could have 100% and app not working. Also need functional tests. Aim for 80%.
  • 13. Test Coverage - Global • Issue: Local coverage can increase and global decrease • Removed code with high TPC • Code tested indirectly by functional tests and code refactoring led to different paths used • New module with lower TPC than average Global TPC evolution
  • 14. Test Coverage - Global • Strategy: • Global Clover TPC computed automatically every night on Jenkins for all repos combined, using a pipeline • Email sent to developers with report in email (see next slide) • But only when global TPC is reduced • Developers fix module they have been working on • Release Manager (RM) ensures that report passes before release & we add one step in our Release Plan check list. Source: http://massol.myxwiki.org/xwiki/bin/view/Blog/ComparingCloverReports
  • 15. Test Coverage - Global
  • 17. Mutation Testing • Using PIT/Gregor, PIT/Descartes • Concepts of PIT • Modify code under test (mutants) and run tests • Good tests kill mutants • Generates a mutation score similar to the coverage % • Descartes = extreme mutations that execute fast and have high values https://massol.myxwiki.org/xwiki/bin/view/Blog/MutationTestingDescartes
  • 20. Mutation - Example result =    (getId() == macroId.getId() || (getId() != null && getId().equals(macroId.getId())))    && (getSyntax() == macroId.getSyntax() || (getSyntax() != null && getSyntax().equals(     macroId.getSyntax())));
  • 21. Mutation - Example @Test public void testEquality() {     MacroId id1 = new MacroId("id", Syntax.XWIKI_2_0);     MacroId id2 = new MacroId("id", Syntax.XWIKI_2_0);     MacroId id3 = new MacroId("otherid", Syntax.XWIKI_2_0);     MacroId id4 = new MacroId("id", Syntax.XHTML_1_0);     MacroId id5 = new MacroId("otherid", Syntax.XHTML_1_0);     MacroId id6 = new MacroId("id");     MacroId id7 = new MacroId("id");     Assert.assertEquals(id2, id1);    // Equal objects must have equal hashcode    Assert.assertTrue(id1.hashCode() == id2.hashCode());     Assert.assertFalse(id3 == id1);     Assert.assertFalse(id4 == id1);     Assert.assertFalse(id5 == id3);     Assert.assertFalse(id6 == id1);     Assert.assertEquals(id7, id6);    // Equal objects must have equal hashcode    Assert.assertTrue(id6.hashCode() == id7.hashCode()); } Not testing for inequality! Improved thanks to Descartes!
  • 22. Mutation - Strategy • Been in place for 1 year now • Fail the build when the mutation score of a given module is below a defined threshold in the pom.xml • The idea is that new tests should, in average, be of quality equal or better than past tests. • Other idea: hook on CI to run it only on modified code/tests. General goal with coverage + mutation: maintain quality
  • 23. Mutation - Limitations • A bit slow, by definition • 2h30 on xwiki • Executed in scheduled jobs (once per day) • PITmp Maven plugin to execute on multi-module • All sources mutated, not just sources where tests are • Much slower as a consequence, and thus difficult to generate a global mutation score
  • 24. Mutation: Going further • Using DSpot • Uses PIT/Descartes but injects results to generate new tests • Adds assertions to existing tests • Generate new test methods • Selector can be PIT/Gregor, PIT/ Descartes, Jacoco (instruction coverage), Clover (Branch coverage) https://massol.myxwiki.org/xwiki/bin/view/Blog/TestGenerationDspot
  • 25. Mutation: Dspot Example 1 public void escapeAttributeValue2() { String escapedText = XMLUtils.escapeAttributeValue("a < a' && a' < a" => a < a" {"); // AssertGenerator add assertion Assert.assertEquals("a &#60; a&#39; &#38;&#38; a&#39; &#60; a&#34; =&#62; a &#60; a&#34; &#123;", escapedText); // AssertGenerator create local variable with return value of invocation boolean o_escapeAttributeValue__3 = escapedText.contains("<"); // AssertGenerator add assertion Assert.assertFalse(o_escapeAttributeValue__3); // AssertGenerator create local variable with return value of invocation boolean o_escapeAttributeValue__4 = escapedText.contains(">"); // AssertGenerator add assertion Assert.assertFalse(o_escapeAttributeValue__4); // AssertGenerator create local variable with return value of invocation boolean o_escapeAttributeValue__5 = escapedText.contains("'"); // AssertGenerator add assertion Assert.assertFalse(o_escapeAttributeValue__5); // AssertGenerator create local variable with return value of invocation boolean o_escapeAttributeValue__6 = escapedText.contains("""); // AssertGenerator create local variable with return value of invocation boolean o_escapeAttributeValue__7 = escapedText.contains("&&"); // AssertGenerator add assertion Assert.assertFalse(o_escapeAttributeValue__7); // AssertGenerator create local variable with return value of invocation boolean o_escapeAttributeValue__8 = escapedText.contains("{"); // AssertGenerator add assertion Assert.assertFalse(o_escapeAttributeValue__8); } Generated test New test @Test public void escapeAttributeValue() { String escapedText = XMLUtils.escapeAttributeValue("a < a' && a' < a" => a < a" {"); assertFalse("Failed to escape <", escapedText.contains("<")); assertFalse("Failed to escape >", escapedText.contains(">")); assertFalse("Failed to escape '", escapedText.contains("'")); assertFalse("Failed to escape "", escapedText.contains(""")); assertFalse("Failed to escape &", escapedText.contains("&&")); assertFalse("Failed to escape {", escapedText.contains("{")); } Original test
  • 26. Mutation: Dspot Example 2 Generated test Original test Also increase coverage Before: 70.5% After: 71.2%
  • 27. Mutation: Dspot Strategy • DSpot is very slow to execute (between 3 to 20mn on small modules) • One strategy is to run it on CI and in the pipeline commit generated tests in a different source root. • And run it only on Tests affected by commit changeset • Configure Maven to add a new test directory source using the Maven Build Helper plugin. • Work in progress: small coverage and mutation score improvements on XWiki so far.
  • 29. Environment Testing • Environment = combination of Servlet container & version, DB & version, OS, Browser & version • And also cluster mode, LibreOffice integration, external SOLR, etc • Need: Be able to run/debug functional tests on local dev machines as well as on CI • Using Docker / TestContainers
  • 32. Environment Testing • Feedback: takes about 3 minutes to deploy all (and 1 minute for the test) • Strategy • Run on CI (Jenkins) • As part of the main pipeline but using the parametrised scheduler plugin • 3 jobs • “latest”: latest version, executes daily • “all”: all supported configs, executed weekly • “unsupported”: all currently unsupported configs, executed monthly
  • 34. Crash Reproduction • Tool: EvoCrash / Botsing • Concept:Take a stack trace and generates a test that, when executed, leads to this stack trace • i.e. find the conditions that leads to the problem
  • 36. Evocrash - Feedback • Can take a long time to reproduce, doesn’t always succeed • Generates a test that reproduces the problem, not the fix! • Often you’d write a test at a different level (usually up in the call chain, to be more meaningful to the use case) • Is useful for newcomers who don’t know the codebase well as it helps pinpoint the problem. Acts as a timesaver.
  • 37. Parting words • Experiment, push the limit! • Some other types of tests not covered and that also need automation • Performance/Stress testing • Usability testing • others? • Functional UI tests and Config tests are hard because of flickers and the required environment stability