-
Notifications
You must be signed in to change notification settings - Fork 41
/
21-testing.Rmd
794 lines (582 loc) Β· 22.3 KB
/
21-testing.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# Testing
**Learning outcomes:**
- Purpose of automated testing
- Different levels of test
- Balance: speed, fragility, coverage
- Reiterate: reactive code needs a reactive context
## Purpose of Automated Testing {-}
> Automated testing is a test method **without much user involvement during the process**.
They increase **robustness** and **reliability** of the application when:
- The application grows
- The development team changes
They ensure that:
- Changes don't break existing code
- Bugs don't arise again
- New code is working expected
## Four levels of testing for shiny apps {-}
> You should always strive to work at the **lowest possible level** so your tests are as **fast** and **robust** as possible.
- **Non-reactive** functions
- **Server function** tests by validating the flow of reactivity.
- **JavaScript** by running the app in a background web browser.
- **App visuals** by saving screenshots of selected elements *(fragile)*.
## Testing Basic structure {-}
1. Turn your app into a package
2. Create a test file for each function
- If you have `R/module.R`
- `usethis::use_test()` will create `tests/testthat/test-module.R`
3. Create tests to check a individual properties of a function by defining one or more `expect_` functions in `test_that()`.
```r
test_that("as.vector() strips names", {
# ARRANGE (GIVEN)
x <- c(a = 1, b = 2)
# ACT (WHEN)
x_unnamed <- as.vector(x)
# ASSERT (THEN)
expect_equal(x_unnamed, c(1, 2))
})
```
## load_file example {-}
1. Create the `R/load.R`.
```r
load_file <- function(name, path) {
ext <- tools::file_ext(name)
switch(ext,
csv = vroom::vroom(path, delim = ",", col_types = list()),
tsv = vroom::vroom(path, delim = "\t", col_types = list()),
shiny::validate("Invalid file; Please upload a .csv or .tsv file")
)
}
```
## load_file example {-}
2. Run `usethis::use_test("load")` and complete the new `test-load.R`.
```r
test_that("load_file() handles all input types", {
# Create sample data
df <- tibble::tibble(x = 1, y = 2)
path_csv <- tempfile()
path_tsv <- tempfile()
write.csv(df, path_csv, row.names = FALSE)
write.table(df, path_tsv, sep = "\t", row.names = FALSE)
# 1. Can it load a csv file ?
expect_equal(load_file("test.csv", path_csv), df)
# 2. Can it load a tsv file ?
expect_equal(load_file("test.tsv", path_tsv), df)
# 3. Does it give an error message for other types?
expect_error(load_file("blah", path_csv), "Invalid file")
})
```
## load_file example {-}
You can also use the `describe()` and `it()` functions to create the `test-load.R` with better error descriptions.
```r
describe("load_file()",{
# Create sample data
df <- tibble::tibble(x = 1, y = 2)
it("can load a csv file",{
path_csv <- tempfile()
write.csv(df, path_csv, row.names = FALSE)
expect_equal(load_file("test.csv", path_csv), df)
})
it("can load a tsv file",{
path_tsv <- tempfile()
write.table(df, path_tsv, sep = "\t", row.names = FALSE)
expect_equal(load_file("test.tsv", path_tsv), df)
})
it("gives an error message for other types",{
expect_error(load_file("blah", path_csv), "Invalid file")
})
})
```
```
> devtools::test()
βΉ Testing quicktest
β | F W S OK | Context
β | 1 2 | load
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Error (test-load.R:21:5): load_file(): gives an error message for other types
```
## Ways to run tests {-}
1. Running each line interactively at the console.
2. Running the whole test block, expecting to see a `Test passed π`.
3. Running all of the tests for the current file using `devtools::test_file()`.
4. Running all of the tests for the whole package using `devtools::test()`.
## Confirming test coverage {-}
1. Install the your current package using `devtools::install_local()`.
2. Run `devtools::test_coverage()` to show you've covered all your functions.
![](images//21-testing/01-testing-coverage.png)
Shortcuts to add to Rstudio:
- [Ctrl + T] : `devtools::test_file()`
- [Ctrl + Shift + R] : `devtools::test_coverage()`
- [Ctrl + R] : `devtools::test_coverage_file()`
## Confirming test coverage {-}
1. Install the your current package using `devtools::install_local()`.
2. Run `devtools::test_coverage()` to show you've covered all your functions.
![](images//21-testing/02-testing-coverage-by-line.png)
## expect_equal {-}
Here a simple example.
```r
complicated_object <- list(
x = list(mtcars, iris),
y = 10
)
expect_equal(complicated_object$y, 10)
```
The most popular cases of expect equal.
|Dedicated function|Equivalent expression|
|:----------------|:-------------------|
|`expect_true(x)`| `expect_equal(x, TRUE)` |
|`expect_false(x)`|`expect_equal(x, FALSE)`|
|`expect_null(x)`|`expect_equal(x, NULL)`|
|`expect_length(x, 10)`|`expect_equal(length(x), 10)`|
|`expect_named(x, c("a", "b", "c"))` |`expect_equal(names(x), c("a", "b", "c"))`|
<br>
> `expect_named()` also has the `ignore.order` and `ignore.case` arguments.
## Relaxed expect_equal {-}
- `expect_setequal(x, y)` tests:
- Every value in `x` occurs in `y`
- Every value in `y` occurs in `x`
<br>
- `expect_mapequal(x, y)` tests:
- `x` and `y` have the same names.
- `x[names(y)] == y`
## expect_error {-}
- You just need to create an error.
```r
expect_error(stop("Bye"))
```
- You can confirm if the error matches
```r
f <- function() {
stop("Calculation failed [location 1]")
}
expect_error(f(), "Calculation failed")
```
- We also have the functions:
- `expect_warning()`
- `expect_message()`
## expect_snapshot for UI functions {-}
> **Expected result is stored in a separate snapshot file**
- If we have
```r
sliderInput01 <- function(id) {
sliderInput(id, label = id, min = 0, max = 1, value = 0.5, step = 0.1)
}
cat(as.character(sliderInput01("x")))
#> <div class="form-group shiny-input-container">
#> <label class="control-label" id="x-label" for="x">x</label>
#> <input class="js-range-slider" id="x" data-skin="shiny" data-min="0" data-max="1" data-from="0.5" data-step="0.1" data-grid="true" data-grid-num="10" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-data-type="number"/>
#> </div>
```
## expect_snapshot for UI functions {-}
> **Expected result is stored in a separate snapshot file**
- If we can also test
```r
test_that("sliderInput01() creates expected HTML", {
expect_equal(as.character(sliderInput01("x")), "<div class=\"form-group shiny-input-container\">\n <label class=\"control-label\" id=\"x-label\" for=\"x\">x</label>\n <input class=\"js-range-slider\" id=\"x\" data-skin=\"shiny\" data-min=\"0\" data-max=\"1\" data-from=\"0.5\" data-step=\"0.1\" data-grid=\"true\" data-grid-num=\"10\" data-grid-snap=\"false\" data-prettify-separator=\",\" data-prettify-enabled=\"true\" data-keyboard=\"true\" data-data-type=\"number\"/>\n</div>")
})
#> Test passed π
```
**But it makes too hard to see if the output changes**
## expect_snapshot for UI functions {-}
- Use `expect_snapshot()` to capture the output displayed on the console.
```r
test_that("sliderInput01() creates expected HTML", {
expect_snapshot(sliderInput01("x"))
})
```
## expect_snapshot for UI functions {-}
- If your test is in `tests/testthat/test-slider.R`, it will save the output in `tests/testhat/_snaps/slider.md`
```md
# sliderInput01() creates expected HTML
Code
sliderInput01("x")
Output
<div class="form-group shiny-input-container">
<label class="control-label" id="x-label" for="x">x</label>
<input class="js-range-slider" id="x" data-skin="shiny" data-min="0" data-max="1" data-from="0.5" data-step="0.1" data-grid="true" data-grid-num="10" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-data-type="number"/>
</div>
```
- If itβs a deliberate change, **update the snapshot by running** `testthat::snapshot_accept()`.
## Testing reactivity {-}
The `testServer()` function (since Shiny 1.5.0) makes it possible to test code in server functions and modules, without needing to run the **full Shiny application** with the following characteristics:
- The UI can not be used.
- You'll need to add a `browser()` inside of `testServer()` to debug any problem.
<br>
<div class="alert warning">
**Note**: For this section, I took some examples the articule [Server function testing](https://shiny.posit.co/r/articles/improve/server-function-testing/) from the original shiny documentation to have a **complete view** of how to use this functionality.
</div>
## Testing reactivity: Initial value {-}
1. Without UI all inputs **always** start as `NULL`.
```r
server <- function(input, output, session) {
# Creates an reactive based on an input
myreactive <- reactive({
input$x * 2
})
# Updates an output
output$txt <- renderText({
paste0("I am ", myreactive())
})
}
testServer(server, {
print(input$x)
})
#> NULL
```
## Testing reactivity: setInputs method {-}
2. We need to add values to inputs by using the `session$setInputs()` method.
```r
testServer(server, {
session$setInputs(x = 10)
print(input$x)
})
#> 10
```
## Testing reactivity: Modules {-}
3. We can test modules with arguments by passing a list to the `args` argument.
```r
myModule2 <- function(id, multiplier) {
moduleServer(id, function(input, output, session) {
myreactive <- reactive({
input$x * multiplier
})
output$txt <- renderText({
paste0("I am ", myreactive())
})
})
}
testServer(myModule2, args = list(multiplier = 3), {
session$setInputs(x = 1)
expect_equal(myreactive(), 3)
})
```
## Testing reactivity: returned method {-}
4. If the module returns an reactive object, the object also can be tested by using the `session$returned()` method.
```r
datasetServer <- function(id) {
moduleServer(id, function(input, output, session) {
reactive(get(input$dataset, "package:datasets"))
})
}
test_that("can find dataset", {
testServer(datasetServer, {
dataset <- session$getReturned()
session$setInputs(dataset = "mtcars")
expect_equal(dataset(), mtcars)
session$setInputs(dataset = "iris")
expect_equal(dataset(), iris)
})
})
#> Test passed πΈ
```
## Testing reactivity: Simulated time {-}
5. testServer uses **simulated time** that you control, rather than the actual computer time.
```r
server <- function(input, output, session){
rv <- reactiveValues(x = 0)
observe({
# Cause the observer to invalidate every 0.1 second
invalidateLater(100)
isolate(rv$x <- rv$x + 1)
})
}
testServer(server, {
expect_equal(rv$x, 0)
Sys.sleep(0.1)
expect_equal(rv$x, 1)
})
#> Error: rv$x (`actual`) not equal to 1 (`expected`).
#>
#> `actual`: 0
#> `expected`: 1
```
## Testing reactivity: elapse method {-}
6. The **simulated time** can be controled by using the `session$elapse()` method.
```r
testServer(server, {
expect_equal(rv$x, 0)
session$elapse(100) # Simulate the passing of 100ms
expect_equal(rv$x, 1) # The observer was invalidated and the value updated!
# You can even simulate multiple events in a single elapse
session$elapse(300)
expect_equal(rv$x, 4)
})
```
> Using this approach, this test can complete in only a **fraction of the 100ms** that it simulates.
- `reactivePoll()`
- `invalidateLater()`
- `reactiveTimer()`
## Testing reactivity: Render outputs {-}
7. It can confirm that a complex result like a plot or htmlwidgets were generated without an error.
```r
server <- function(input, output, session){
# Move any complex logic into a separate reactive
# which can be tested comprehensively
plotData <- reactive({
data.frame(length = iris$Petal.Length, width = iris$Petal.Width)
})
# And leave the `render` function to be as simple as possible
# to lessen the need for integration tests.
output$plot <- renderPlot({
plot(plotData())
})
}
testServer(server, {
# Confirm that the data reactive is behaving as expected
expect_equal(nrow(plotData()), 150)
expect_equal(ncol(plotData()), 2)
expect_equal(colnames(plotData()), c("length", "width"))
# Just confirming that the plot can be accessed without an error
output$plot
})
```
## Testing reactivity: flushReact method {-}
8. If your module functions recives reactives as additinal arguments, you will need to use the `session$flushReact()` method to update the related outputs.
```r
summaryServer <- function(id, var) {
stopifnot(is.reactive(var))
moduleServer(id, function(input, output, session) {
range_val <- reactive(range(var(), na.rm = TRUE))
output$min <- renderText(range_val()[[1]])
output$max <- renderText(range_val()[[2]])
output$mean <- renderText(mean(var()))
})
}
test_that("output updates when reactive input changes", {
x <- reactiveVal()
testServer(summaryServer, args = list(var = x), {
x(1:10)
session$flushReact()
expect_equal(range_val(), c(1, 10))
expect_equal(output$mean, "5.5")
x(10:20)
session$flushReact()
expect_equal(range_val(), c(10, 20))
expect_equal(output$min, "10")
})
})
#> Test passed π
```
## testServer limitations {-}
`testServer()`won't run any needed JavaScript, so the results of the following functions won't work:
- All `update*()` functions
- `showNotification()` / `removeNotification()`
- `showModal()` / `hideModal()`
- `insertUI()` / `removeUI()` / `appendTab()` / `insertTab()`/ `removeTab()`
## Testing JavaScript {-}
<div class="alert primary">
As shinytest has been **deprecated** as it was based on PhantomJS, we are going to use the **shinytest2** based on the **chromote** package and *Google Chrome (Chromium)* browser to reproduce the example of the chapter.
</div>
Limitations:
- This technique is slower than the other approaches.
- Only test the outside of the app can be tested.
- Visual tests are best run by one person on their **local computer** as itβs hard to get different computers to generate **pixel-reproducible screenshots**.
<div class="alert warning">
If you are facing problems testing your app as it needs **wait** until the complition of some CSS animations, you can use the **selenider** packages as it will automatically **wait for your code to work**.
</div>
## Example with observeEvent (shinylive) {-}
<iframe height="500" width="100%" frameborder="no" src="https://shinylive.io/r/app/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAGwEsAjAJykYE8AKAZwAtaJWAlAB0IIgK60ABAB4AtJIBm1CQBMAClADmcdiMmTyAD1IBJCKjGldkWHCF5J9gOrcopAOSdJrImMaToeHsBXD0DOGMAeUsLK3tNRjg4Uj5NYNCIfSgCFJIAIUtSEmtEzmT7XEcwLDgy0mCRYVEIMsYANzh-OUUxCBzaYr5Yyt9SYckyzk4BiAFJEDDR2IASBKSUiE0ZeUSIFU6AFQirBcz9SUSAR3Yhy2XAuCbzyVQoTnIABmsACSkKyVupHutiekgAvqCiPRWh0AKIdMg3cx3UrJSpiVAqNxwI7GMyxLi1aYkSr2B7-NpQZRwSQAXiqwSaYJEIh4fFYAEF0OwJJUYZ0BGAwQBdIA"> </iframe>
## Example with observeEvent {-}
```r
library(shiny)
ui <- fluidPage(
textInput("name", "What's your name"),
textOutput("greeting"),
actionButton("reset", "Reset")
)
server <- function(input, output, session) {
output$greeting <- renderText({
req(input$name)
paste0("Hi ", input$name)
})
observeEvent(input$reset, updateTextInput(session, "name", value = ""))
}
```
## Headless interaction {-}
```r
library(shinytest2)
app <- AppDriver$new(shinyApp(ui, server))
app$set_inputs(name = "Hadley")
app$get_value(output = "greeting")
#> [1] "Hi Hadley"
app$click("reset")
app$get_value(output = "greeting")
#> $message
#> [1] ""
#>
#> $call
#> [1] "NULL"
#>
#> $type
#> [1] "shiny.silent.error" "validation"
```
## Testing headless interaction {-}
```r
test_that("can set and reset name", {
app <- AppDriver$new(shinyApp(ui, server))
app$set_inputs(name = "Hadley")
expect_equal(app$get_value(output = "greeting"), "Hi Hadley")
app$click("reset")
expect_equal(app$get_value(output = "greeting")$message, "")
})
#> Test passed π₯
```
## Example with updateRadioButtons (shinylive) {-}
<iframe height="500" width="100%" frameborder="no" src="https://shinylive.io/r/app/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAGwEsAjAJykYE8AKAZwAtaJWAlAB0IIgK60ABAB4AtJIBm1CQBMAClADmcdiMmTmK2kQBCY0qRKddYBYwmkheSU4Dq3KKQDknSayJijIpQAG4BjLTkivaRAPxOuHr6kgTcRLQEcABysHC+ALySdJykuhDJyU5oqNRwCS7lFS5gqHAs9UkV5AAepACSEKjmNkSk3HCM9dRQ9HDUkoVZAKoAMiu4kjVQmWnUKhMLzQDyYxNOwo36AomXKWkZcABqUMp5hwQ21bUdLW2Tzk5RuN-hcrhskj1SEdzENSk4Qi8xHUwBcLiJOBMQgc5IoxBACKRjBB2HxYRsAqQyZIMZxOESBJIQEkiPQMYwsQBRLFkEmDcwAEiBEw2tE0ECIjDgA0ihwAKlglhyNkzbmJUCpPHAsFAjKZzJYINYaXSSODbDFHM4MbUCXAVIdAacQUkAL6gyqNCmw-kI14yeSSiD7RiyuC9dgqiq0BSSXneuwOBaFR3A86MzrJSUARzjAqFjHdUb5pEFTozLskcwx6du+lJAoTkXLrouLpEIgAxJIAMKSzWSADKvH4kmqklkE9k6OHrAAguh2BJDhINmysUFCmuJhcwC6ALpAA"> </iframe>
## Example with updateRadioButtons {-}
```r
ui <- fluidPage(
radioButtons("fruit", "What's your favourite fruit?",
choiceNames = list(
"apple",
"pear",
textInput("other", label = NULL, placeholder = "Other")
),
choiceValues = c("apple", "pear", "other")
),
textOutput("value")
)
server <- function(input, output, session) {
observeEvent(input$other, ignoreInit = TRUE, {
updateRadioButtons(session, "fruit", selected = "other")
})
output$value <- renderText({
if (input$fruit == "other") {
req(input$other)
input$other
} else {
input$fruit
}
})
}
```
## Testing without UI {-}
```r
test_that("returns other value when primary is other", {
testServer(server, {
session$setInputs(fruit = "apple")
expect_equal(output$value, "apple")
session$setInputs(fruit = "other", other = "orange")
expect_equal(output$value, "orange")
})
})
#> Test passed π₯
```
## Testing without UI {-}
**Check that other is automatically** selected when we start typing in the other box.
```r
test_that("returns other value when primary is other", {
testServer(server, {
session$setInputs(fruit = "apple", other = "orange")
expect_equal(output$value, "orange")
})
})
#> ββ Failure (<text>:2:3): returns other value when primary is other βββββββββββββ
#> output$value (`actual`) not equal to "orange" (`expected`).
#>
#> `actual`: "apple"
#> `expected`: "orange"
#> Backtrace:
#> 1. shiny::testServer(...)
#> 22. testthat::expect_equal(output$value, "orange")
#> Error in `reporter$stop_if_needed()`:
#> ! Test failed
```
## Testing with UI {-}
```r
test_that("automatically switches to other", {
# Defining the app
app <- AppDriver$new(shinyApp(ui, server))
# Start typing a new fruit
app$set_inputs(other = "orange")
# Fruit must change to other
expect_equal(app$get_value(input = "fruit"), "other")
# The final output should show the typed orange
expect_equal(app$get_value(output = "value"), "orange")
})
#> Test passed π
```
## Testing visuals {-}
- The second argument to `expect_snapshot_file()` gives the file name that the image will be saved in file snapshot directory.
- If these tests are in a file called `test-app.R`, the snapshots will be saved:
- `tests/testthat/_snaps/app/plot-init.png`
- `tests/testthat/_snaps/app/plot-update.png`
- To visualise the differences in a Shiny App run `testthat::snapshot_review()`
```r
# Loading the app
app <- AppDriver$new(shinyApp(ui, server))
# Defining path to save screeenshot
path <- tempfile(fileext = ".png")
# Save screenshot to temporary file
app$get_screenshot(path)
expect_snapshot_file(path, "plot-init.png")
# Changing the input
app$set_inputs(x = 2)
app$get_screenshot(path)
expect_snapshot_file(path, "plot-update.png")
```
## When should you write tests? {-}
- Before you write the code
- After you write the code
- When you find a bug
## Other interesting things {-}
- [Shinytest2 Vs Cypress: End-To-End (E2E) Testing In Shiny](https://www.appsilon.com/post/shinytest2-vs-cypress-e2e-testing)
- one of the {tinytest} vignettes has
["a few tips on packages and unit testing"](
https://cran.r-project.org/web/packages/tinytest/vignettes/using_tinytest.pdf
)
- two nice visualisations of
[the TDD cycle](https://www.obeythetestinggoat.com/book/chapter_philosophy_and_refactoring.html#simple-TDD-diagram),
and of
[TDD-until-the-feature's ready](https://www.obeythetestinggoat.com/book/chapter_philosophy_and_refactoring.html#Double-Loop-TDD-diagram)
are in "Test-Driven Development with Python" by Harry Percival.
- ["R Packages"](https://r-pkgs.org/tests.html) has a chapter about "testthat"
- The RStudio "shiny" website has
[three articles / webinars](https://shiny.rstudio.com/articles/testing-overview.html)
on testing in shiny
- chapter-section on testing in
["Engineering Production-Grade Shiny Apps"](https://engineering-shiny.org/build-yourself-safety-net.html#testing-your-app)
## Meeting Videos
### Cohort 1
`r knitr::include_url("https://www.youtube.com/embed/8ZTGDbH1MaE")`
### Cohort 2
`r knitr::include_url("https://www.youtube.com/embed/nwAg54rA3xs")`
<details>
<summary> Meeting chat log </summary>
```
00:08:40 collinberke: https://github.com/collinberke/ga4WebDash
00:43:42 Kevin Gilds: https://rich-iannone.github.io/pointblank/
00:50:43 Kevin Gilds: https://github.com/yonicd/covrpage
```
</details>
`r knitr::include_url("https://www.youtube.com/embed/eguok48Piyg")`
### Cohort 3
`r knitr::include_url("https://www.youtube.com/embed/MNf6w_FpxVw")`
<details>
<summary>Meeting chat log</summary>
```
00:28:35 Oluwafemi Oyedele: https://github.com/collinberke/ga4WebDash
00:58:38 Oluwafemi Oyedele: https://adv-r.hadley.nz/names-values.html#gc
```
</details>
### Cohort 4
`r knitr::include_url("https://www.youtube.com/embed/7Uz0Mh2gMfk")`
<details>
<summary>Meeting chat log</summary>
```
00:10:54 Trevin Flickinger: start
00:12:01 Trevin Flickinger: https://rstudio-conf-2022.github.io/build-tidy-tools/
00:12:19 Trevin Flickinger: https://rstudio-conf-2022.github.io/build-tidy-tools/materials/day-1-session-3-testing.html#/title-slide
00:21:47 Trevin Flickinger: https://r-pkgs.org/index.html
00:27:17 Matthew Efoli: thank you
00:42:42 Trevin Flickinger: https://github.com/rstudio-conf-2022/ussie
01:04:39 Trevin Flickinger: stop
```
</details>
### Cohort 5
`r knitr::include_url("https://www.youtube.com/embed/URL")`
<details>
<summary>Meeting chat log</summary>
```
LOG
```
</details>