SlideShare a Scribd company logo
How and Why
Developers Migrate
Python Tests
Lívia Barbosa, Andre Hora
1
IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER, 2022)
Motivation
Why Python? Why test migration?
2
3
TIOBE Index:
https:/
/www.tiobe.com/tiobe-index Github Search Results
One of the most popular programming languages
Testing Frameworks
4
Unittest
- JUnit based
- Included in the Python
Standard Library
Testing Frameworks
5
Unittest
- JUnit based
- Included in the Python
Standard Library
Pytest
- Third-party testing
framework
- Lighter-weight syntax
Testing Frameworks
6
Testing Frameworks
7
Class and Assert Migration (TermGraph, d56652)
8
unittest pytest
Fixture Migration (pyvim, 7e1c7b)
9
unittest pytest
10
Problem
Despite being largely performed by the Python
community, we are not yet aware of:
- How software projects are migrated from
unittest to pytest
- The reasons behind the migrations
Research Questions
0. (extension) To what extent are unittest and pytest
adopted in the Python ecosystem over time?
1. (frequency) How frequent is code migrated from
unittest to pytest?
2. (duration) How long does it take to migrate from
unittest to pytest?
3. (transformations) What code is migrated from unittest
to pytest?
4. (reasons) Why is code migrated from unittest to pytest?
11
Study design
12
Study Design
1. Case Studies: Top-100 real-world systems
2. Detecting Testing Frameworks over time
3. Assessing migration
4. Pull Requests and Issues
13
Top-100 most popular real-world systems
14
1 - Case Studies
2 - Detecting Testing
Frameworks
Assess present and past versions of the system
15
3 - Assessing migration
◉ Migration Commits
○ PyDriller
○ Verify removed and added lines per commit
◉ Migration Stage
16
17
3 - Assessing migration
Code Transformations
18
Type of Migration Unittest API Pytest API
Assert self.assert* assert
Fixture setUp, tearDown & its
variations
@pytest.fixture,
@pytest.mark.usefixtures
Import import unittest import pytest
Skip @unittest.skip* @pytest.mark.skip,
@pytest.mark.skipif
Expected failure @unittest.expectedFailure @pytest.mark.xfail
3 - Assessing migration
19
◉ Query Github Search API for "unittest to pytest"
◉ Filtered out false positives, resulting in 61
◉ Thematic analysis to classify them
20
4 - Pull Request
and Issues
Results
RQ0: Extension, RQ1: frequency, RQ2: duration,
RQ3: transformations, RQ4 reasons
21
RQ0: Extension
To what extent are unittest and pytest adopted in the
Python ecosystem over time?
22
RQ0: Extension
To what extent are unittest and pytest adopted in the
Python ecosystem over time?
23
RQ0: Extension
To what extent are unittest and pytest adopted in the
Python ecosystem over time?
24
RQ0: Extension
To what extent are unittest and pytest adopted in the
Python ecosystem over time?
25
RQ0: Extension
To what extent are unittest and pytest adopted in the
Python ecosystem over time?
Most systems (77 out of 100) rely on unittest (20%),
pytest (23%), or both (34%). Moreover, projects with
unittest are moving to pytest: 66% (39 out of 59) of the
systems initially with unittest now rely on pytest.
26
RQ1: Frequency
How frequent is code migrated from unittest to pytest?
27
RQ1: Frequency
How frequent is code migrated from unittest to pytest?
From the 39 systems that started with unittest and
adopted pytest over time, 28% (11) have fully migrated
to pytest, 41% (16) are still migrating, and 31% (12) did
not migrate.
28
RQ2: Duration
How long does it take to migrate from unittest to
pytest?
29
RQ2: Duration
How long does it take to migrate from unittest to
pytest? When the migration started?
30
RQ2: Duration
How long does it take to migrate from unittest to
pytest? When the migration started?
The migration may be fast (up to one week) or take a long
period to be concluded, from months to years. Most
migrated systems (8 out of 11) tend to concentrate the
migration commits, while only 3 perform the migration more
sparsely. Systems start the migration in distinct development
stages, from early to late ones.
31
RQ3: Transformations
What code is migrated from unittest to pytest?
32
RQ3: Transformations
What code is migrated from unittest to pytest?
33
RQ3: Transformations
What code is migrated from unittest to pytest?
The majority (90%) of the migration commits include
assert migrations. Developers also tend to migrate
fixtures (18%) and imports (13%). Overall, the migrated
test code is 34% smaller than the original one, meaning
fewer test code to be maintained.
34
RQ4: Reasons
Why is code migrated from unittest to pytest?
35
Easier syntax: “[...] the pytest syntax is nicer, and allows us to
take advantage of things like fixtures”
Interoperability: "we can run the legacy unittests"
Easier maintenance: "It would be nice to migrate the test over
to pytest-django to get rid of most of the boilerplate code"
Fixture flexibility/reuse: "There is a powerful fixtures system
to support cleaner setup/teardown code, which supports
per-test, per-class, per-module and global fixtures"
36
RQ4: Reasons
Implicit mechanics: “There's a lot of 'magic' involved in the
internals, which can be confusing”
"Be careful with the 'magic': in particular, fixtures can
sometimes be overused in ways that make test code hard to
follow because too much is happening behind the scenes"
New tool to learn, Multiple test styles and Migration duration:
"Another tool to learn for contributors [...] Either we end up
with multiple styles of test or there's a lot of work in rewriting
existing tests"
37
RQ4: Reasons
Why is code migrated from unittest to pytest?
Developers migrate from unittest to pytest mostly due
to the easier syntax, interoperability, easier
maintenance, and fixture flexibility/reuse. Disadvantages
are less discussed, but the implicit mechanics of pytest
is the main concern.
38
RQ4: Reasons
Discussions and
Implications
39
◉ Migration practices, advantages, and
disadvantages.
◉ Keep track of the migration.
◉ Improve migration guidelines.
40
For practitioners
For Researchers
◉ Why the migration is not concluded.
◉ Tools and techniques to document and
automate the migration.
41
Threats to Validity
◉ Framework usage and migration commits
◉ Mocking libraries
◉ Manual classification of issues/PRs
◉ Generalization of the results
42
Review
To what extent are they
adopted?
20% unittest, 23% pytest,
34% on both.
66% (39 out of 59) unittest
projects are moving to
pytest.
How frequent is the
migration?
From the 39 systems
initially with unittest, 28%
fully migrated, 41% is still
migrating
How long does it take?
May be fast or slow, most
systems concentrate
migration commits, and
they start the migration in
different development
stages.
43
Research Questions and Results
Review
44
Research Questions and Results
What code is migrated?
90% of the migration
commits include assert
migrations. Overall, the
migrated test code is 34%
smaller
Why does it happen?
Easier syntax,
interoperability, easier
maintenance, and fixture
flexibility/reuse. Implicit
mechanics is a concern.
◉ The first empirical assess the migration of
testing frameworks in Python systems
◉ How code is migrated and the reasons for the
migration
◉ Propose practical implications for practitioners
and researchers
45
Conclusion
Any questions?
Thanks!
46
Ad

More Related Content

Similar to How and Why Developers Migrate Python Tests (SANER 2022) (20)

Replication and Benchmarking in Software Analytics
Replication and Benchmarking in Software AnalyticsReplication and Benchmarking in Software Analytics
Replication and Benchmarking in Software Analytics
University of Zurich
 
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Amine Barrak
 
Synthesizing Knowledge from Software Development Artifacts
Synthesizing Knowledge from Software Development ArtifactsSynthesizing Knowledge from Software Development Artifacts
Synthesizing Knowledge from Software Development Artifacts
Jeongwhan Choi
 
Continuous delivery practices and real experiences
Continuous delivery   practices and real experiencesContinuous delivery   practices and real experiences
Continuous delivery practices and real experiences
Eduardo Ferro Aldama
 
Introduction to Civil Infrastructure Platform
Introduction to Civil Infrastructure PlatformIntroduction to Civil Infrastructure Platform
Introduction to Civil Infrastructure Platform
SZ Lin
 
Implementing Observability for Kubernetes.pdf
Implementing Observability for Kubernetes.pdfImplementing Observability for Kubernetes.pdf
Implementing Observability for Kubernetes.pdf
Jose Manuel Ortega Candel
 
Agile maintenance
Agile maintenanceAgile maintenance
Agile maintenance
aralikatte
 
DevOps State of the Union 2015
DevOps State of the Union 2015DevOps State of the Union 2015
DevOps State of the Union 2015
Ernest Mueller
 
An Empirical Comparison of the Development History of CloudStack and Eucalyptus
An Empirical Comparison of the Development History of CloudStack and EucalyptusAn Empirical Comparison of the Development History of CloudStack and Eucalyptus
An Empirical Comparison of the Development History of CloudStack and Eucalyptus
Ahmed Zerouali
 
From construction to deployment of LifeWatchGreece the potentail role of EGI-...
From construction to deployment of LifeWatchGreece the potentail role of EGI-...From construction to deployment of LifeWatchGreece the potentail role of EGI-...
From construction to deployment of LifeWatchGreece the potentail role of EGI-...
Emmanouella Panteri
 
Microservices.pdf
Microservices.pdfMicroservices.pdf
Microservices.pdf
SelmaJelovac1
 
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Weaveworks
 
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
University of Antwerp
 
Continuous Delivery for people who do not write code - Matthew Skelton - Conflux
Continuous Delivery for people who do not write code - Matthew Skelton - ConfluxContinuous Delivery for people who do not write code - Matthew Skelton - Conflux
Continuous Delivery for people who do not write code - Matthew Skelton - Conflux
Matthew Skelton
 
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Amine Barrak
 
Predicting rainfall with data science in python
Predicting rainfall with data science in pythonPredicting rainfall with data science in python
Predicting rainfall with data science in python
dhanushthurinjikuppa
 
Solving the 3 Biggest Questions in Continuous Testing
Solving the 3 Biggest Questions in Continuous TestingSolving the 3 Biggest Questions in Continuous Testing
Solving the 3 Biggest Questions in Continuous Testing
Perfecto by Perforce
 
Introducing the Civil Infrastructure Platform
Introducing the Civil Infrastructure PlatformIntroducing the Civil Infrastructure Platform
Introducing the Civil Infrastructure Platform
Yoshitake Kobayashi
 
Distributed Tracing with Jaeger
Distributed Tracing with JaegerDistributed Tracing with Jaeger
Distributed Tracing with Jaeger
Inho Kang
 
Opentracing jaeger
Opentracing jaegerOpentracing jaeger
Opentracing jaeger
Oracle Korea
 
Replication and Benchmarking in Software Analytics
Replication and Benchmarking in Software AnalyticsReplication and Benchmarking in Software Analytics
Replication and Benchmarking in Software Analytics
University of Zurich
 
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Amine Barrak
 
Synthesizing Knowledge from Software Development Artifacts
Synthesizing Knowledge from Software Development ArtifactsSynthesizing Knowledge from Software Development Artifacts
Synthesizing Knowledge from Software Development Artifacts
Jeongwhan Choi
 
Continuous delivery practices and real experiences
Continuous delivery   practices and real experiencesContinuous delivery   practices and real experiences
Continuous delivery practices and real experiences
Eduardo Ferro Aldama
 
Introduction to Civil Infrastructure Platform
Introduction to Civil Infrastructure PlatformIntroduction to Civil Infrastructure Platform
Introduction to Civil Infrastructure Platform
SZ Lin
 
Implementing Observability for Kubernetes.pdf
Implementing Observability for Kubernetes.pdfImplementing Observability for Kubernetes.pdf
Implementing Observability for Kubernetes.pdf
Jose Manuel Ortega Candel
 
Agile maintenance
Agile maintenanceAgile maintenance
Agile maintenance
aralikatte
 
DevOps State of the Union 2015
DevOps State of the Union 2015DevOps State of the Union 2015
DevOps State of the Union 2015
Ernest Mueller
 
An Empirical Comparison of the Development History of CloudStack and Eucalyptus
An Empirical Comparison of the Development History of CloudStack and EucalyptusAn Empirical Comparison of the Development History of CloudStack and Eucalyptus
An Empirical Comparison of the Development History of CloudStack and Eucalyptus
Ahmed Zerouali
 
From construction to deployment of LifeWatchGreece the potentail role of EGI-...
From construction to deployment of LifeWatchGreece the potentail role of EGI-...From construction to deployment of LifeWatchGreece the potentail role of EGI-...
From construction to deployment of LifeWatchGreece the potentail role of EGI-...
Emmanouella Panteri
 
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Weaveworks
 
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...Keynote VST2020 (Workshop on  Validation, Analysis and Evolution of Software ...
Keynote VST2020 (Workshop on Validation, Analysis and Evolution of Software ...
University of Antwerp
 
Continuous Delivery for people who do not write code - Matthew Skelton - Conflux
Continuous Delivery for people who do not write code - Matthew Skelton - ConfluxContinuous Delivery for people who do not write code - Matthew Skelton - Conflux
Continuous Delivery for people who do not write code - Matthew Skelton - Conflux
Matthew Skelton
 
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Just-in-time Detection of Protection-Impacting Changes on WordPress and Media...
Amine Barrak
 
Predicting rainfall with data science in python
Predicting rainfall with data science in pythonPredicting rainfall with data science in python
Predicting rainfall with data science in python
dhanushthurinjikuppa
 
Solving the 3 Biggest Questions in Continuous Testing
Solving the 3 Biggest Questions in Continuous TestingSolving the 3 Biggest Questions in Continuous Testing
Solving the 3 Biggest Questions in Continuous Testing
Perfecto by Perforce
 
Introducing the Civil Infrastructure Platform
Introducing the Civil Infrastructure PlatformIntroducing the Civil Infrastructure Platform
Introducing the Civil Infrastructure Platform
Yoshitake Kobayashi
 
Distributed Tracing with Jaeger
Distributed Tracing with JaegerDistributed Tracing with Jaeger
Distributed Tracing with Jaeger
Inho Kang
 
Opentracing jaeger
Opentracing jaegerOpentracing jaeger
Opentracing jaeger
Oracle Korea
 

More from Andre Hora (14)

Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
When should internal interfaces be promoted to public? (FSE 2016)
When should internal interfaces be promoted to public? (FSE 2016)When should internal interfaces be promoted to public? (FSE 2016)
When should internal interfaces be promoted to public? (FSE 2016)
Andre Hora
 
Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)
Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)
Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)
Andre Hora
 
JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
Andre Hora
 
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Andre Hora
 
What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)
What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)
What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)
Andre Hora
 
Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...
Andre Hora
 
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Andre Hora
 
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Andre Hora
 
Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...
Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...
Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...
Andre Hora
 
PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)
PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)
PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)
Andre Hora
 
Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)
Andre Hora
 
SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)
SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)
SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)
Andre Hora
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
When should internal interfaces be promoted to public? (FSE 2016)
When should internal interfaces be promoted to public? (FSE 2016)When should internal interfaces be promoted to public? (FSE 2016)
When should internal interfaces be promoted to public? (FSE 2016)
Andre Hora
 
Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)
Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)
Assessing the Threat of Untracked Changes in Software Evolution (ICSE 2018)
Andre Hora
 
JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
Andre Hora
 
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Andre Hora
 
What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)
What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)
What Code Is Deliberately Excluded from Test Coverage and Why? (MSR 2021)
Andre Hora
 
Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...
Andre Hora
 
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Andre Hora
 
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Andre Hora
 
Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...
Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...
Monitoring the Execution of 14K Tests: Methods Tend to Have One Path that Is ...
Andre Hora
 
PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)
PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)
PathSpotter: Exploring Tested Paths to Discover Missing Tests (FSE 2024)
Andre Hora
 
Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)
Andre Hora
 
SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)
SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)
SpotFlow: Tracking Method Calls and States at Runtime (ICSE 2024)
Andre Hora
 
Ad

Recently uploaded (20)

Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Foundation Models for Time Series : A Survey
Foundation Models for Time Series : A SurveyFoundation Models for Time Series : A Survey
Foundation Models for Time Series : A Survey
jayanthkalyanam1
 
Creating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdfCreating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdf
Applitools
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Full Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest VersionFull Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest Version
jonesmichealj2
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game DevelopmentBest Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Juego Studios
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025
younisnoman75
 
Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025
fs4635986
 
Microsoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptxMicrosoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptx
Mekonnen
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Foundation Models for Time Series : A Survey
Foundation Models for Time Series : A SurveyFoundation Models for Time Series : A Survey
Foundation Models for Time Series : A Survey
jayanthkalyanam1
 
Creating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdfCreating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdf
Applitools
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Full Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest VersionFull Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest Version
jonesmichealj2
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game DevelopmentBest Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Juego Studios
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025
younisnoman75
 
Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025
fs4635986
 
Microsoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptxMicrosoft Excel Core Points Training.pptx
Microsoft Excel Core Points Training.pptx
Mekonnen
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Ad

How and Why Developers Migrate Python Tests (SANER 2022)

  • 1. How and Why Developers Migrate Python Tests Lívia Barbosa, Andre Hora 1 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER, 2022)
  • 2. Motivation Why Python? Why test migration? 2
  • 3. 3 TIOBE Index: https:/ /www.tiobe.com/tiobe-index Github Search Results One of the most popular programming languages
  • 4. Testing Frameworks 4 Unittest - JUnit based - Included in the Python Standard Library
  • 5. Testing Frameworks 5 Unittest - JUnit based - Included in the Python Standard Library Pytest - Third-party testing framework - Lighter-weight syntax
  • 8. Class and Assert Migration (TermGraph, d56652) 8 unittest pytest
  • 9. Fixture Migration (pyvim, 7e1c7b) 9 unittest pytest
  • 10. 10 Problem Despite being largely performed by the Python community, we are not yet aware of: - How software projects are migrated from unittest to pytest - The reasons behind the migrations
  • 11. Research Questions 0. (extension) To what extent are unittest and pytest adopted in the Python ecosystem over time? 1. (frequency) How frequent is code migrated from unittest to pytest? 2. (duration) How long does it take to migrate from unittest to pytest? 3. (transformations) What code is migrated from unittest to pytest? 4. (reasons) Why is code migrated from unittest to pytest? 11
  • 13. Study Design 1. Case Studies: Top-100 real-world systems 2. Detecting Testing Frameworks over time 3. Assessing migration 4. Pull Requests and Issues 13
  • 14. Top-100 most popular real-world systems 14 1 - Case Studies
  • 15. 2 - Detecting Testing Frameworks Assess present and past versions of the system 15
  • 16. 3 - Assessing migration ◉ Migration Commits ○ PyDriller ○ Verify removed and added lines per commit ◉ Migration Stage 16
  • 17. 17 3 - Assessing migration
  • 18. Code Transformations 18 Type of Migration Unittest API Pytest API Assert self.assert* assert Fixture setUp, tearDown & its variations @pytest.fixture, @pytest.mark.usefixtures Import import unittest import pytest Skip @unittest.skip* @pytest.mark.skip, @pytest.mark.skipif Expected failure @unittest.expectedFailure @pytest.mark.xfail
  • 19. 3 - Assessing migration 19
  • 20. ◉ Query Github Search API for "unittest to pytest" ◉ Filtered out false positives, resulting in 61 ◉ Thematic analysis to classify them 20 4 - Pull Request and Issues
  • 21. Results RQ0: Extension, RQ1: frequency, RQ2: duration, RQ3: transformations, RQ4 reasons 21
  • 22. RQ0: Extension To what extent are unittest and pytest adopted in the Python ecosystem over time? 22
  • 23. RQ0: Extension To what extent are unittest and pytest adopted in the Python ecosystem over time? 23
  • 24. RQ0: Extension To what extent are unittest and pytest adopted in the Python ecosystem over time? 24
  • 25. RQ0: Extension To what extent are unittest and pytest adopted in the Python ecosystem over time? 25
  • 26. RQ0: Extension To what extent are unittest and pytest adopted in the Python ecosystem over time? Most systems (77 out of 100) rely on unittest (20%), pytest (23%), or both (34%). Moreover, projects with unittest are moving to pytest: 66% (39 out of 59) of the systems initially with unittest now rely on pytest. 26
  • 27. RQ1: Frequency How frequent is code migrated from unittest to pytest? 27
  • 28. RQ1: Frequency How frequent is code migrated from unittest to pytest? From the 39 systems that started with unittest and adopted pytest over time, 28% (11) have fully migrated to pytest, 41% (16) are still migrating, and 31% (12) did not migrate. 28
  • 29. RQ2: Duration How long does it take to migrate from unittest to pytest? 29
  • 30. RQ2: Duration How long does it take to migrate from unittest to pytest? When the migration started? 30
  • 31. RQ2: Duration How long does it take to migrate from unittest to pytest? When the migration started? The migration may be fast (up to one week) or take a long period to be concluded, from months to years. Most migrated systems (8 out of 11) tend to concentrate the migration commits, while only 3 perform the migration more sparsely. Systems start the migration in distinct development stages, from early to late ones. 31
  • 32. RQ3: Transformations What code is migrated from unittest to pytest? 32
  • 33. RQ3: Transformations What code is migrated from unittest to pytest? 33
  • 34. RQ3: Transformations What code is migrated from unittest to pytest? The majority (90%) of the migration commits include assert migrations. Developers also tend to migrate fixtures (18%) and imports (13%). Overall, the migrated test code is 34% smaller than the original one, meaning fewer test code to be maintained. 34
  • 35. RQ4: Reasons Why is code migrated from unittest to pytest? 35
  • 36. Easier syntax: “[...] the pytest syntax is nicer, and allows us to take advantage of things like fixtures” Interoperability: "we can run the legacy unittests" Easier maintenance: "It would be nice to migrate the test over to pytest-django to get rid of most of the boilerplate code" Fixture flexibility/reuse: "There is a powerful fixtures system to support cleaner setup/teardown code, which supports per-test, per-class, per-module and global fixtures" 36 RQ4: Reasons
  • 37. Implicit mechanics: “There's a lot of 'magic' involved in the internals, which can be confusing” "Be careful with the 'magic': in particular, fixtures can sometimes be overused in ways that make test code hard to follow because too much is happening behind the scenes" New tool to learn, Multiple test styles and Migration duration: "Another tool to learn for contributors [...] Either we end up with multiple styles of test or there's a lot of work in rewriting existing tests" 37 RQ4: Reasons
  • 38. Why is code migrated from unittest to pytest? Developers migrate from unittest to pytest mostly due to the easier syntax, interoperability, easier maintenance, and fixture flexibility/reuse. Disadvantages are less discussed, but the implicit mechanics of pytest is the main concern. 38 RQ4: Reasons
  • 40. ◉ Migration practices, advantages, and disadvantages. ◉ Keep track of the migration. ◉ Improve migration guidelines. 40 For practitioners
  • 41. For Researchers ◉ Why the migration is not concluded. ◉ Tools and techniques to document and automate the migration. 41
  • 42. Threats to Validity ◉ Framework usage and migration commits ◉ Mocking libraries ◉ Manual classification of issues/PRs ◉ Generalization of the results 42
  • 43. Review To what extent are they adopted? 20% unittest, 23% pytest, 34% on both. 66% (39 out of 59) unittest projects are moving to pytest. How frequent is the migration? From the 39 systems initially with unittest, 28% fully migrated, 41% is still migrating How long does it take? May be fast or slow, most systems concentrate migration commits, and they start the migration in different development stages. 43 Research Questions and Results
  • 44. Review 44 Research Questions and Results What code is migrated? 90% of the migration commits include assert migrations. Overall, the migrated test code is 34% smaller Why does it happen? Easier syntax, interoperability, easier maintenance, and fixture flexibility/reuse. Implicit mechanics is a concern.
  • 45. ◉ The first empirical assess the migration of testing frameworks in Python systems ◉ How code is migrated and the reasons for the migration ◉ Propose practical implications for practitioners and researchers 45 Conclusion