Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit 6594efe

Browse files
author
Venkatesh-Prasad Ranganath
committed
Placing course content of Software Testing Techniques Course in a public
repo.
0 parents  commit 6594efe

File tree

533 files changed

+292779
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

533 files changed

+292779
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

LICENSE.txt

Lines changed: 396 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Software Testing Techniques Course
2+
3+
This is the content of software testing techniques course offered at Kansas State University in Spring'16 and Spring'17. It was intended for upper undergraduates (seniors) and beginning graduates. It required students to have taken courses on programming, logic, software design, and discrete mathematics.
4+
5+
Here are some aspects of the course.
6+
- Class room instruction revolved around open questions posed to students. [Socratic Method]
7+
- Students answers were collected on the whiteboard and discussed to arrive at "expert" answers.
8+
- Students directed instructor in live coding sessions to arrive at "expert" solutions.
9+
- Sketch slides were used in class to drive discussion. The same slides were extended with highlights from classroom discussion and posted after class.
10+
- Homework questions were seeded with ambiguity to simulate specification elicitation to resolve ambiguity and, consequently, identify testing boundaries.
11+
- Textbooks were not required as there were none that described most of topics covered in the course.
12+
- Few fringe/newer topics such as mutation testing and BDD were discussed in the course.
13+
14+
The content contains
15+
- content slide deck interspersed with answers collected in class and answers for homework,
16+
- quiz question bank,
17+
- homework assignments along with solutions and scripts to evaluate submissions,
18+
- extra credit assignments along with solutions and scripts to evaluate submissions, and
19+
- mid-term and end-term exams with solutions.
20+
21+
I hope folks will find this useful.
22+
23+
24+
## Attribution
25+
26+
Copyright (c) 2017, Venkatesh-Prasad Ranganath
27+
28+
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
29+
30+
**Author/Creator: Venkatesh-Prasad Ranganath**
58.5 KB
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from behave import given, when, then, step
2+
from src import account
3+
4+
5+
@given('my current account has $200')
6+
def current_account_setup(context):
7+
context.current = account.Account(200)
8+
9+
10+
@step('My savings account has $1000')
11+
def savings_account_setup(context):
12+
context.savings = account.Account(1000)
13+
14+
15+
@when('I transfer $100 from my current account to savings account')
16+
def execute_transfer(context):
17+
context.current.transfer(100, context.savings)
18+
19+
20+
@then('I should have $100 in my current account')
21+
def verify_current_account(context):
22+
assert context.current.amount() == 100
23+
24+
25+
@step('I should have $1100 in my savings account')
26+
def verify_savings_account(context):
27+
assert context.savings.amount() == 1100
28+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Transfer money between accounts
2+
To manage my money efficiently
3+
As a bank client
4+
I want to transfer funds between accts
5+
6+
Scenario: Transfer money with sufficient funds
7+
Given my current account has $200
8+
And my savings account has $1000
9+
When I transfer $100 from my current account to savings account
10+
Then I should have $100 in my current account
11+
And I should have $1100 in my savings account
12+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Account:
2+
def __init__(self, amount):
3+
self._amount = amount
4+
5+
def transfer(self, amount, dest_account):
6+
dest_account._amount = dest_account._amount + amount
7+
self._amount = self._amount - amount
8+
9+
def amount(self):
10+
return self._amount
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from behave import given, when, then, step
2+
from src import account
3+
4+
5+
@given('my current account has ${amount}')
6+
def current_account_setup(context, amount):
7+
context.current = account.Account(int(amount))
8+
9+
10+
@step('My savings account has ${amount}')
11+
def savings_account_setup(context, amount):
12+
context.savings = account.Account(int(amount))
13+
14+
15+
@when('I transfer ${amount} from my current account to savings account')
16+
def execute_transfer(context, amount):
17+
context.current.transfer(int(amount), context.savings)
18+
19+
20+
@then('I should have ${amount} in my current account')
21+
def verify_current_account(context, amount):
22+
assert context.current.amount() == int(amount)
23+
24+
25+
@step('I should have ${amount} in my savings account')
26+
def verify_savings_account(context, amount):
27+
assert context.savings.amount() == int(amount)
28+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Transfer money between accounts
2+
To manage my money efficiently
3+
As a bank client
4+
I want to transfer funds between accts
5+
6+
Scenario: Transfer money with sufficient funds
7+
Given my current account has $200
8+
And my savings account has $1000
9+
When I transfer $100 from my current account to savings account
10+
Then I should have $100 in my current account
11+
And I should have $1100 in my savings account
12+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Account:
2+
def __init__(self, amount):
3+
self._amount = amount
4+
5+
def transfer(self, amount, dest_account):
6+
dest_account._amount = dest_account._amount + amount
7+
self._amount = self._amount - amount
8+
9+
def amount(self):
10+
return self._amount
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from behave import given, when, then, step
2+
from src import account
3+
4+
5+
6+
@given('my current account has ${amount}')
7+
def current_account_setup(context, amount):
8+
context.current = account.Account(int(amount))
9+
10+
11+
@step('My savings account has ${amount}')
12+
def savings_account_setup(context, amount):
13+
context.savings = account.Account(int(amount))
14+
15+
16+
@when('I transfer ${amount} from my current account to savings account')
17+
def execute_transfer(context, amount):
18+
context.current.transfer(int(amount), context.savings)
19+
20+
21+
@then('I should have ${amount} in my current account')
22+
def verify_current_account(context, amount):
23+
assert context.current.amount() == int(amount)
24+
25+
26+
@step('I should have ${amount} in my savings account')
27+
def verify_savings_account(context, amount):
28+
assert context.savings.amount() == int(amount)
29+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Transfer money between accounts
2+
To manage my money efficiently
3+
As a bank client
4+
I want to transfer funds between accts
5+
6+
Scenario Outline: Transfer money with sufficient funds
7+
Given my current account has $<init1>
8+
And my savings account has $<init2>
9+
When I transfer $<withdraw> from my current account to savings account
10+
Then I should have $<balance1> in my current account
11+
And I should have $<balance2> in my savings account
12+
13+
Examples: T
14+
| init1 | init2 | withdraw | balance1 | balance2 |
15+
| 200 | 1000 | 100 | 100 | 1100 |
16+
| 400 | 3000 | 200 | 200 | 3200 |
17+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Account:
2+
def __init__(self, amount):
3+
self._amount = amount
4+
5+
def transfer(self, amount, dest_account):
6+
dest_account._amount = dest_account._amount + amount
7+
self._amount = self._amount - amount
8+
9+
def amount(self):
10+
return self._amount
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from behave import given, when, then, step
2+
from src import account
3+
4+
5+
@given('my current account has ${amount}')
6+
def current_account_setup(context, amount):
7+
context.current = account.Account(int(amount))
8+
9+
10+
@step('My savings account has ${amount}')
11+
def savings_account_setup(context, amount):
12+
context.savings = account.Account(int(amount))
13+
14+
15+
@when('I transfer ${amount} from my current account to savings account')
16+
def execute_transfer(context, amount):
17+
context.current.transfer(int(amount), context.savings)
18+
19+
20+
@then('I should have ${amount} in my current account')
21+
def verify_current_account(context, amount):
22+
assert context.current.amount() == int(amount)
23+
24+
25+
@step('I should have ${amount} in my savings account')
26+
def verify_savings_account(context, amount):
27+
assert context.savings.amount() == int(amount)
28+
29+
30+
@when('I transfer ${amount} from my current account to savings account (modified)')
31+
def execute_transfer(context, amount):
32+
try:
33+
context.curr_amount = context.current.amount()
34+
context.sav_amount = context.savings.amount()
35+
context.current.transfer(int(amount), context.savings)
36+
context.exception = None
37+
except RuntimeError as e:
38+
context.exception = e
39+
40+
41+
@then('I should see an error message "Insufficient funds"')
42+
def step_impl(context):
43+
assert context.exception.args[0] == "Insufficient funds"
44+
45+
46+
@then('the amount in my current account should be unchanged')
47+
def step_impl(context):
48+
assert context.current.amount() == context.curr_amount
49+
50+
51+
@then('the amount in my savings account should be unchanged')
52+
def step_impl(context):
53+
assert context.savings.amount() == context.sav_amount
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Feature: Transfer money between accounts
2+
To manage my money efficiently
3+
As a bank client
4+
I want to transfer funds between accts
5+
6+
Scenario: Transfer money with sufficient funds
7+
Given my current account has $200
8+
And my savings account has $1000
9+
When I transfer $100 from my current account to savings account
10+
Then I should have $100 in my current account
11+
And I should have $1100 in my savings account
12+
13+
Scenario: Transfer money with insufficient funds
14+
Given my current account has $200
15+
And my savings account has $1000
16+
When I transfer $500 from my current account to savings account (modified)
17+
Then I should see an error message "Insufficient funds"
18+
And the amount in my savings account should be unchanged
19+
And the amount in my current account should be unchanged
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Account:
2+
def __init__(self, amount):
3+
self._amount = amount
4+
5+
def transfer(self, amount, dest_account):
6+
if amount > self._amount:
7+
raise RuntimeError("Insufficient funds")
8+
dest_account._amount = dest_account._amount + amount
9+
self._amount = self._amount - amount
10+
11+
def amount(self):
12+
return self._amount
Binary file not shown.
9.36 KB
Binary file not shown.
117 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
include=impl.py
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import re
2+
3+
class PhysicalInfo(object):
4+
5+
def set_height(self, height):
6+
if not isinstance(height, int):
7+
raise ValueError("height should be an integer")
8+
if height < 17 or height > 84:
9+
raise ValueError("height should be an integer between 17 and 84")
10+
self.height = height
11+
if height < 17:
12+
print("Boom")
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
INSTALL
2+
pip install pytest-html
3+
4+
5+
EXECUTION
6+
pytest --html=report.html
7+
8+
9+
INSTALL
10+
pip install pytest-cov
11+
12+
13+
EXECUTION:
14+
py.test --cov-report=term --cov=.
15+
- terminal output for all code in current folder
16+
17+
py.test --cov-report=term-missing --cov=.
18+
- terminal output for all code in current folder
19+
- with listing of missed line numbers
20+
21+
py.test --cov-report=term-missing --cov=. --cov-config=coverage.rc
22+
- terminal output for all code in current folder
23+
- with listing of missed line numbers
24+
- with specific coverage configuration to control which bit of code needs to be measured
25+
26+
py.test --cov-report=term-missing --cov=. --cov-config=coverage.rc --cov-fail-under=95
27+
- terminal output for all code in current folder
28+
- with listing of missed line numbers
29+
- with specific coverage configuration to control which bit of code needs to be measured
30+
- report coverage less than 95# as failure
31+
32+
py.test --cov-report=html --cov=. --cov-config=coverage.rc
33+
- terminal output for all code in current folder
34+
- with listing of missed line numbers
35+
- with specific coverage configuration to control which bit of code needs to be measured
36+
37+
py.test --cov-report=html --cov=. --cov-config=coverage.rc --cov-fail-under=95
38+
- html output for all code in current folder
39+
- with listing of missed line numbers
40+
- with specific coverage configuration to control which bit of code needs to be measured
41+
- report coverage less than 95% as failure
42+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# py.test --cov-report=term --cov=. --cov-config=coverage.rc --cov-fail-under=100
2+
3+
from impl import PhysicalInfo
4+
import pytest
5+
6+
def test_e1():
7+
t = PhysicalInfo()
8+
with pytest.raises(ValueError):
9+
t.set_height("Michael")
10+
11+
def test_e2():
12+
t = PhysicalInfo()
13+
with pytest.raises(ValueError):
14+
t.set_height(100)
15+
16+
def test_e3():
17+
t = PhysicalInfo()
18+
t.set_height(50)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# py.test --cov-report=term --cov=. --cov-config=coverage.rc --cov-fail-under=100
2+
3+
from impl import PhysicalInfo
4+
import pytest
5+
import hypothesis.strategies as st
6+
from hypothesis import given, assume
7+
8+
@given(st.floats() | st.text() | st.booleans())
9+
def test_p1(v):
10+
t = PhysicalInfo()
11+
with pytest.raises(ValueError):
12+
t.set_height(v)
13+
14+
@given(st.integers())
15+
def test_p2(v):
16+
assume(v < 17 or v > 84)
17+
t = PhysicalInfo()
18+
with pytest.raises(ValueError):
19+
t.set_height(v)
20+
21+
@given(st.integers())
22+
def test_p3(v):
23+
assume(v >= 17 and v <= 84)
24+
t = PhysicalInfo()
25+
t.set_height(v)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/rvprasad/Documents/Courses/CIS640/content/coverage-criteria/code-snippets-1/test_impl_with_examples.py": [], "/Users/rvprasad/Documents/Courses/CIS640/content/coverage-criteria/code-snippets-1/test_impl_with_properties.py": [3, 4, 5, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25], "/Users/rvprasad/Documents/Courses/CIS640/content/coverage-criteria/code-snippets-1/impl.py": [1, 3, 54, 55, 56, 57, 58, 59]}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
include=impl.py

0 commit comments

Comments
 (0)