jeudi 31 mars 2016

Unit Testing Shiny Apps

So I have been writing a fairly detailled shiny app, and in the future will need updating as the functionality behind what is run is constantly changing.

What I need to be able to do is have unit tests (either using testthat or another library more useful for shiny apps) that enables me to run these tests in a more automated fashion.

I have written a simple shiny app. For the sake of testing in this would like a way to know that if I choose the number 20 in the numeric input then I get 400 as the output$out text. But want to be able to do this without actually running the app myself.

library(shiny)

ui <- fluidPage(title = 'Test App', 
    numericInput('num', 'Number', 50, 1, 100, 0.5),
    'Numeric output',
    textOutput('out')
)

server <- function(input, output, session) {
  aux <- reactive(input$num ^ 2)

  output$out <- renderText(aux())
}

shinyApp(ui = ui, server = server)

Aucun commentaire:

Enregistrer un commentaire