Skip to content

Commit 419daac

Browse files
authored
improve some examples
java -> python clarifications fix issues from previous versions
1 parent 7da7995 commit 419daac

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

Session_1.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test('email validation fails on a wrong email', () => {
2626

2727
```javascript
2828
import { db } from './db'
29-
import { validateEmail } from './validators'
29+
import { saltAndHash } from './security'
3030

3131
function createUser(email, password) {
3232
const preliminaryUsername = email.split('@')[0]
@@ -50,12 +50,12 @@ test('createUser should extract the username from the email', () => {
5050

5151
## Example 3
5252

53-
```java
54-
public class User {
53+
```python
54+
class User:
5555
...
56-
public String getName() {
57-
return this.name
58-
}
56+
57+
def getName(self):
58+
return self.name
59+
5960
...
60-
}
6161
```

Session_2.md

+20-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ These are all the examples for the quiz in the second Automated Testing LU sessi
66

77
```javascript
88
test('BankAccount: Withdraw from Account', (account) => {
9-
const transaction = account.deposit(5)
9+
account.setBalance(0)
10+
account.deposit(5)
1011

1112
expect(account.withdraw(5)).equals(true)
1213
expect(account.withdraw(1)).equals(false)
@@ -18,6 +19,11 @@ test('BankAccount: Withdraw from Account', (account) => {
1819
## Example 2
1920

2021
```javascript
22+
// NOTE:
23+
// You can assume all functions like "fillField" have a built-in way of waiting
24+
// until the necessary element exists, and if the element doesn't exist until a
25+
// previously-specified timeout, the test fails.
26+
2127
test('user can log in and change their username', (I) => {
2228
// automatically open a browser tab with this url
2329
I.amOnPage('https://myawesomewebsite.com/')
@@ -51,19 +57,18 @@ test('user can log in and change their username', (I) => {
5157
## Example 3
5258

5359
```javascript
54-
import { testFramework } from 'test-framework'
60+
import { createMockFunction } from 'test-framework'
5561
import { userRepository } from './userRepository'
56-
import { db } from './db'
5762

5863
test('User repository should save userdata to database', () => {
5964
// given
6065
const user = { name: "Anna", age: 28 }
61-
const saveToTableMock = testFramework.createMockFunction(
66+
const saveToTableMock = createMockFunction(
6267
function(table, data) {
6368
console.log('TABLE:', table, '| data:', data)
6469
}
6570
)
66-
userRepository.mock(db, { saveToTable: saveToTableMock })
71+
userRepository.mock({ saveToTable: saveToTableMock })
6772
// when
6873
userRepository.saveUser(user)
6974
// then
@@ -73,13 +78,14 @@ test('User repository should save userdata to database', () => {
7378

7479
## Example 4
7580

76-
```java
77-
/** Return a date object representing the start of the next minute from now */
78-
public Date nextMinuteFromNow() {
79-
long nowAsMillis = System.currentTimeMillis();
80-
Date then = new Date(nowAsMillis + 60000);
81-
then.setSeconds(0);
82-
then.setMilliseconds(0);
83-
return then;
84-
}
81+
```python
82+
def nextMinuteFromNow():
83+
'''
84+
Return a date object representing the start of the next minute from now
85+
'''
86+
nowAsMillis = currentTimeInMilliseconds()
87+
then = Date(nowAsMillis + 60000)
88+
then.setSeconds(0)
89+
then.setMilliseconds(0)
90+
return then
8591
```

0 commit comments

Comments
 (0)