Tests

Published

2024-12-20

Expand the callout boxes below to review what we’ve covered in the previous chapters on debugging:

In the Exploring code chapter we covered:

The applications in Chapter 10 (Exploring code) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 10 applications:

list_apps(regex = '^10')
## # A tibble: 2 × 2
##   branch        last_updated       
##   <chr>         <dttm>             
## 1 10_debugger   2024-12-15 03:02:26
## 2 10_test-suite 2024-09-23 12:05:04

In the Debugging apps chapter we covered:

The applications in Chapter 11 (Debugging apps) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 11 applications:

list_apps(regex = '^11')
## # A tibble: 2 × 2
##   branch         last_updated       
##   <chr>          <dttm>             
## 1 11_debug-print 2024-11-20 22:09:54
## 2 11_tests-specs 2024-09-03 22:33:22

In the Print debugging chapter we covered:

The applications in Chapter 11 (Print debugging) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 12 applications:

list_apps(regex = '^12')
## # A tibble: 3 × 2
##   branch               last_updated       
##   <chr>                <dttm>             
## 1 12.1_tests-fixtures  2024-09-14 07:13:41
## 2 12.2_tests-helpers   2024-09-03 22:39:27
## 3 12.3_tests-snapshots 2024-11-06 08:09:57

In the Exploring code chapter we covered:

The applications in Chapter 13 (Utility functions) can be accessed with the launch() or get() functions from the shinypak R package:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
library(shinypak)

Chapter 13 applications:

list_apps(regex = '^13')
## # A tibble: 1 × 2
##   branch           last_updated       
##   <chr>            <dttm>             
## 1 13_tests-modules 2024-09-03 23:11:59

Testing your app

We’re now ready to test the code and features in our app-package. The next section covers the following topics:

Test suite

Test suite starts by showing how to create the testthat infrastructure then, dives into creating test files, the mechanics unit tests and expectations, and running tests during development

This chapter also introduces keyboard shortcuts for testing and testthat’s behavior-driven development functions:

Specifications

Specifications discusses how to collect and organize information to write tests for your application:

This chapter also gives examples of behavior-driven development tests features and how to track specifications and tests together:

Test tools

This chapter introduces:

Each tool can contribute to testing your Shiny app-package in a unique way (they’re also relatively recent additions to the testthat framework)

Testing modules

Shiny’s testServer() function can be useful for performing integration tests with module server functions. Testing modules gives examples of using testServer() to verify module communication (i.e., passing data between modules):

System tests

The final chapter in this section covers setting up and running system (or end-to-end tests with shinytest2):

Please open an issue on GitHub