This presentation explores how AI can revolutionize agile development practices through the lens of GitHub Copilot. Attendees will gain a deep understanding of GitHub Copilot's capabilities, including its ability to suggest code completions, write entire functions, and even generate unit tests. ...
This presentation explores how AI can revolutionize agile development practices through the lens of GitHub Copilot. Attendees will gain a deep understanding of GitHub Copilot's capabilities, including its ability to suggest code completions, write entire functions, and even generate unit tests. We will delve into specific use cases, demonstrating how Copilot can enhance Behavior Driven Development (BDD) and Test-Driven Development (TDD) methodologies. By leveraging AI, developers can significantly improve their productivity, code quality, and overall development experience.
Size: 748.03 KB
Language: en
Added: Aug 23, 2024
Slides: 31 pages
Slide Content
Integrating AI into Test-Driven
Practices
July 11, 2024
Raj Indugula
About Me
2
•18+ years of Agile
with focus on
integrating technical
practices
•Lean-Agile-DevOps
practitioner,
consultant and
trainer
•Trusted partner in
helping organizations
transition to agile;
deepening adoption
with Engineering &
DevOps discipline
Making peoples’ work
more valued, productive
and fulfilling
Industry Recognition
Making peoples’
work more valued,
productive and
fulfilling
Raj Indugula, SVP, Agile Consulting
LitheSpeed
3
GitHub CoPilot: An Introduction
AI-Boosted Behavior Driven Development (BDD)
AI-Boosted Test Driven Development (TDD)
Guidelines & Considerations
Outline
GitHub CoPilot: An Introdution
What is GitHub CoPilot?
AI-powered coding assistant that assists
developers by generating code suggestions
based on context and existing code patterns
5
Integrates with popular Integrated Development Environments (IDEs)
AI Pair Programmer
Helps developers by:
•Suggesting code snippets
•Auto-completing lines or blocks of code
•Generating unit tests
•Providing relevant documentation
6
ACTIVITY PRODUCTIVITY EFFICIENCY SATISFACTION
35%
Acceptance rate
50%
More pull requests
50%
More builds
96%
Successful on day one
88%
Characters retained
15%
Higher merge rate
45%
Higher success rate
90%
More fulfilled
https://github.blog/2024-05-13-research-quantifying-github-copilots-impact-in-the-enterprise-with-accenture/
6-month study of 450 developers
How does it work?
7
GitHub CoPilot
OpenAI
Provide
Context
Provide
Suggestions
All data deleted from memory
Code Editor
Prompt
Prompt Crafting
8
Intent
Vague: "Help me with my
work.”
Clear: "Help me draft an
email to invite colleagues
to a meeting."
Clarity
Vague: "Plan an event.”
Clear: "Plan a one-hour
virtual team meeting with
an agenda and a list of
participants."
Specificity
Vague: "Organize files.”
Clear: "Organize the
photos from our last
company event into
folders by date."
What’s included as Context?
9
The entirety of the file, not
just where the cursor is
Current File
Tabs closest to the active
tab given priority
Tabs Open in Editor
What does it mean
to be test-driven?
Scenario: Invalid example
Given I am a new user
When I select "Abc1*$!-**" as
a password
Then I can access my account
Scenario: Cash dispensed
when machine has no $20
bills
Given the ATM is out of $20
bills
When a depositor withdraws
$50
Then the ATM dispenses 5
$10 bills
Building the
right thing
Building the
thing right
Acceptance
Tests
(BDD)
Thinking in Tests
Source Adaptation: Raj Indugula & George Dinwiddie
AI-Boosted Behavior Driven
Development (BDD)
What is Behavior Driven Development (BDD)?
13
Collaboration and conversation to
discover essential requirements and identify uncertainty
using examples expressed in a common language
to build a shared understanding to deliver software that matters
Gherkin: Bridging the Gap
15
Business-
readable
specifications
Automated
tests
Gherkin: Feature-Scenario-Steps
16
Feature: ATM withdrawals
Our ATM allows depositors to withdraw their funds in cash
Rules:
Withdrawals are limited by amount on deposit
Withdrawals are subject to daily and transaction withdrawal limits
Cash is dispensed in $10 increments with $20 bills favored
Scenario: Sufficient funds allows withdrawal
Given a depositor has $2000 on deposit
When the depositor requests $200
Then the ATM dispenses $200
And the depositor’s balance is reduced to $1800
…
Think about some test scenarios…
Before we look at using
CoPilot, let’s look at a
couple of stories and
brainstorm some potential
test scenarios.
17
Depositinto
account
Withdrawfrom
account
Bank Account
Management
Feature
Transfer…
Pay bills…
18
We’ll see VS Code with GitHub Copilot in action where we
experiment with different levels of detail to observe how
that affects the results generated by the AI tool.
AI-Boosted Test Driven
Development (TDD)
Style of
programming in
which three
activities are tightly
interwoven: coding,
testing (in the form
of writingunit tests)
and design (in the
form ofrefactoring)
What is Test-Driven Development (TDD)?
20
Write a
new test
Test
Fails
Write
Code
Test
Passes
Clean up
code,
make
sure tests
pass
Red – Green - Refactor
21
We’ll see VS Code with GitHub Copilot in action where we
pair with our AI pair programmer to test drive the code
Guidelines & Considerations
Copilot suggestions
contain mistakes
making it to
production
Limitations
23
Source: The Promise and Peril of GitHub Copilot
Code Churn: % of code reverted or updated within 2 weeks
Analysis of over 150 million lines of code changes between 2020 and 2023
To implement AI tools, you need…
24
Technical Skills
Prompt Crafting
•Craft clear and specific prompts
•Experiment and iterate to improve prompts
Code Reviews
•AI-generated code may have errors; review for
accuracy
•Ensure code changes meet requirements
Testing and Security
•Automate tests with AI but verify critical functions
•Ensure comprehensive test coverage
Problem Solving
•Think creatively to overcome complex challenges
•Adapt to changing circumstances and
technologies
Adaptability
•Embrace new AI tools and frameworks
•Maintain a growth mindset for continuous learning
Empathy
•Understand and prioritize user needs &
preferences
•Ensure AI solutions enhance user experiences
Soft Skills
Take this with you
25
Always invite AI to the table
Always be the human in the loop
Assume this is the worst AI you will
ever use
Source inspiration: Co-Intelligence, Living and Working with AI , Ethan Mollick
From Test-Last to Test-Driven….with your AI Pair Programmer
Source Adaptation: Raj Indugula & George Dinwiddie
Scenario: Invalid example
Given I am a new user
When I select "Abc1*$!-**" as
a password
Then I can access my account
Scenario: Cash dispensed
when machine has no $20
bills
Given the ATM is out of $20
bills
When a depositor withdraws
$50
Then the ATM dispenses 5
$10 bills
Building the right
thing
Building the thing
right
Acceptance
Tests
(BDD)
Setting up GitHub Copilot
29
•Prerequisites:
•You must have an active GitHub Copilot subscription
•To use GitHub Copilot in Visual Studio Code, you must have Visual Studio Code installed
•In Visual Studio Code:
•Go to extensions, select GitHub Copilot, and click Install
•Be sure to also install GitHub Copilot Chat
•You will need to authorize Visual Studio Code in your GitHub account
•If you are not prompted to authorize, click the Bell icon at the bottom of VS Code
•After installation, to disable or enable GitHub Copilot, click the status icon at the bottom of VS
Code
GitHub Copilot Basics
30
•In your code, start typing, and Copilot will automatically suggest some code. Accept the
suggestion by tabbing.
Seeing Alternate Suggestions Partially Accepting Suggestions
•Also, you can generate code suggestions from comments. Just describe something you want to
do using natural language in a comment, and Copilot will generate code trying to match the intent
you communicated in your comment.
Helpful / and @ commands in Chat
31
Command Description
/explain Get code explanations
/fix Receive a proposed fix for the problems in the selected code
/tests Generate unit tests for selected code
/help Get help on using Copilot Chat
/clear Clear current conversation
/doc Add a documentation comment
/generate Generate code to answer your question
/optimize Analyze and improve running time of the selected code
/clear Clear current chat
/new Scaffold code for a new workspace
/simplify Simplify the selected code
/feedback Provide feedback to the team