@@ -6,7 +6,8 @@ These are all the examples for the quiz in the second Automated Testing LU sessi
6
6
7
7
``` javascript
8
8
test (' BankAccount: Withdraw from Account' , (account ) => {
9
- const transaction = account .deposit (5 )
9
+ account .setBalance (0 )
10
+ account .deposit (5 )
10
11
11
12
expect (account .withdraw (5 )).equals (true )
12
13
expect (account .withdraw (1 )).equals (false )
@@ -18,6 +19,11 @@ test('BankAccount: Withdraw from Account', (account) => {
18
19
## Example 2
19
20
20
21
``` 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
+
21
27
test (' user can log in and change their username' , (I ) => {
22
28
// automatically open a browser tab with this url
23
29
I .amOnPage (' https://myawesomewebsite.com/' )
@@ -51,19 +57,18 @@ test('user can log in and change their username', (I) => {
51
57
## Example 3
52
58
53
59
``` javascript
54
- import { testFramework } from ' test-framework'
60
+ import { createMockFunction } from ' test-framework'
55
61
import { userRepository } from ' ./userRepository'
56
- import { db } from ' ./db'
57
62
58
63
test (' User repository should save userdata to database' , () => {
59
64
// given
60
65
const user = { name: " Anna" , age: 28 }
61
- const saveToTableMock = testFramework . createMockFunction (
66
+ const saveToTableMock = createMockFunction (
62
67
function (table , data ) {
63
68
console .log (' TABLE:' , table, ' | data:' , data)
64
69
}
65
70
)
66
- userRepository .mock (db, { saveToTable: saveToTableMock })
71
+ userRepository .mock ({ saveToTable: saveToTableMock })
67
72
// when
68
73
userRepository .saveUser (user)
69
74
// then
@@ -73,13 +78,14 @@ test('User repository should save userdata to database', () => {
73
78
74
79
## Example 4
75
80
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
85
91
```
0 commit comments