Difference between revisions of "RPR-Unit testing"
m |
m |
||
Line 28: | Line 28: | ||
== Abstract == | == Abstract == | ||
<section begin=abstract /> | <section begin=abstract /> | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "abstract" --> |
This unit discusses how to put tests in R into practice with the testthat package. | This unit discusses how to put tests in R into practice with the testthat package. | ||
<section end=abstract /> | <section end=abstract /> | ||
Line 37: | Line 37: | ||
== This unit ... == | == This unit ... == | ||
=== Prerequisites === | === Prerequisites === | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "prerequisites" --> |
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "notes-prerequisites" --> |
You need to complete the following units before beginning this one: | You need to complete the following units before beginning this one: | ||
*[[FND-CSC-Test_driven_development|FND-CSC-Test_driven_development (Test Driven Development)]] | *[[FND-CSC-Test_driven_development|FND-CSC-Test_driven_development (Test Driven Development)]] | ||
Line 46: | Line 46: | ||
=== Objectives === | === Objectives === | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "objectives" --> |
This unit will ... | This unit will ... | ||
* ... introduce the testthat package; | * ... introduce the testthat package; | ||
Line 56: | Line 56: | ||
=== Outcomes === | === Outcomes === | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "outcomes" --> |
After working through this unit you ... | After working through this unit you ... | ||
* ... can write your own tests; | * ... can write your own tests; | ||
Line 65: | Line 65: | ||
=== Deliverables === | === Deliverables === | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "deliverables" --> |
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "deliverables-time_management" --> |
*<b>Time management</b>: Before you begin, estimate how long it will take you to complete this unit. Then, record in your course journal: the number of hours you estimated, the number of hours you worked on the unit, and the amount of time that passed between start and completion of this unit. | *<b>Time management</b>: Before you begin, estimate how long it will take you to complete this unit. Then, record in your course journal: the number of hours you estimated, the number of hours you worked on the unit, and the amount of time that passed between start and completion of this unit. | ||
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "deliverables-journal" --> |
*<b>Journal</b>: Document your progress in your [[FND-Journal|Course Journal]]. Some tasks may ask you to include specific items in your journal. Don't overlook these. | *<b>Journal</b>: Document your progress in your [[FND-Journal|Course Journal]]. Some tasks may ask you to include specific items in your journal. Don't overlook these. | ||
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "deliverables-insights" --> |
*<b>Insights</b>: If you find something particularly noteworthy about this unit, make a note in your [[ABC-Insights|'''insights!''' page]]. | *<b>Insights</b>: If you find something particularly noteworthy about this unit, make a note in your [[ABC-Insights|'''insights!''' page]]. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{{Vspace}} | {{Vspace}} | ||
Line 88: | Line 79: | ||
<div id="BIO"> | <div id="BIO"> | ||
== Contents == | == Contents == | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "contents" --> |
{{ABC-unit|RPR-Unit_testing.R}} | {{ABC-unit|RPR-Unit_testing.R}} | ||
Line 105: | Line 96: | ||
== Notes == | == Notes == | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "notes" --> |
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "notes" --> |
<references /> | <references /> | ||
Line 115: | Line 106: | ||
<div id="ABC-unit-framework"> | <div id="ABC-unit-framework"> | ||
== Self-evaluation == | == Self-evaluation == | ||
− | <!-- included from " | + | <!-- included from "./components/RPR-Unit_testing.components.txt", section: "self-evaluation" --> |
<!-- | <!-- | ||
=== Question 1=== | === Question 1=== | ||
Line 140: | Line 131: | ||
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "ABC-unit_ask" --> |
---- | ---- | ||
Line 168: | Line 159: | ||
</div> | </div> | ||
[[Category:ABC-units]] | [[Category:ABC-units]] | ||
− | <!-- included from "ABC-unit_components. | + | <!-- included from "./data/ABC-unit_components.txt", section: "ABC-unit_footer" --> |
{{CC-BY}} | {{CC-BY}} |
Revision as of 01:27, 6 January 2018
Testing R code
Keywords: Code testing in R with the testthat package
Contents
Abstract
This unit discusses how to put tests in R into practice with the testthat package.
This unit ...
Prerequisites
You need to complete the following units before beginning this one:
Objectives
This unit will ...
- ... introduce the testthat package;
- ... teach how to write tests;
- ... demonstrate best practice to organize your tests.
Outcomes
After working through this unit you ...
- ... can write your own tests;
- ... can organize your tests in files and a testing directory to simplify running them.
Deliverables
- Time management: Before you begin, estimate how long it will take you to complete this unit. Then, record in your course journal: the number of hours you estimated, the number of hours you worked on the unit, and the amount of time that passed between start and completion of this unit.
- Journal: Document your progress in your Course Journal. Some tasks may ask you to include specific items in your journal. Don't overlook these.
- Insights: If you find something particularly noteworthy about this unit, make a note in your insights! page.
Contents
Task:
- Open RStudio and load the
ABC-units
R project. If you have loaded it before, choose File → Recent projects → ABC-Units. If you have not loaded it before, follow the instructions in the RPR-Introduction unit. - Choose Tools → Version Control → Pull Branches to fetch the most recent version of the project from its GitHub repository with all changes and bug fixes included.
- Type
init()
if requested. - Open the file
RPR-Unit_testing.R
and follow the instructions.
Note: take care that you understand all of the code in the script. Evaluation in this course is cumulative and you may be asked to explain any part of code.
Further reading, links and resources
Notes
Self-evaluation
If in doubt, ask! If anything about this learning unit is not clear to you, do not proceed blindly but ask for clarification. Post your question on the course mailing list: others are likely to have similar problems. Or send an email to your instructor.
About ...
Author:
- Boris Steipe <boris.steipe@utoronto.ca>
Created:
- 2017-08-05
Modified:
- 2017-08-05
Version:
- 1.0
Version history:
- 1.0 New contents
- 0.1 First stub
This copyrighted material is licensed under a Creative Commons Attribution 4.0 International License. Follow the link to learn more.