{"id":14066464,"url":"https://github.com/dgkf/testex","last_synced_at":"2025-04-14T00:56:44.051Z","repository":{"id":55004840,"uuid":"502498600","full_name":"dgkf/testex","owner":"dgkf","description":"Add tests and assertions in-line in R package examples","archived":false,"fork":false,"pushed_at":"2024-04-04T17:02:00.000Z","size":7154,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-05T17:22:31.308Z","etag":null,"topics":["documentation","examples","r","rlang","roxygen2","testing"],"latest_commit_sha":null,"homepage":"https://dgkf.github.io/testex/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgkf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-12T02:14:03.000Z","updated_at":"2024-04-14T19:37:53.420Z","dependencies_parsed_at":"2024-03-26T05:21:44.794Z","dependency_job_id":"d99f8158-d0f9-4a9a-b2c1-6130ff042c6a","html_url":"https://github.com/dgkf/testex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Ftestex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Ftestex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Ftestex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgkf%2Ftestex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgkf","download_url":"https://codeload.github.com/dgkf/testex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804784,"owners_count":21164131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documentation","examples","r","rlang","roxygen2","testing"],"created_at":"2024-08-13T07:05:06.803Z","updated_at":"2025-04-14T00:56:44.030Z","avatar_url":"https://github.com/dgkf.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# `testex` ***test examples*** \u003cimg src=\"https://user-images.githubusercontent.com/18220321/211960830-8c969bee-8c80-4984-8132-b5993911f179.png\" align=\"right\" width=\"134px\"/\u003e\n\n[![CRAN](https://img.shields.io/cran/v/testex.svg)](https://cran.r-project.org/package=testex)\n[![`R CMD check`](https://github.com/dgkf/testex/workflows/R-CMD-check/badge.svg)](https://github.com/dgkf/testex/actions?query=workflow%3AR-CMD-check)\n[![coverage](https://img.shields.io/codecov/c/github/dgkf/testex/main.svg)](https://app.codecov.io/gh/dgkf/testex) \n\nAdd tests and assertions in-line in examples\n\n## Quick Start\n\nSet up your package to use `testex` using\n\n```r\ntestex::use_testex()\n```\n\nand then start adding tests!\n\n```r\n#' Hello, World!\n#' \n#' @examples\n#' hello(\"World\")\n#' @test \"Hello, World!\"\n#'\n#' hello(\"darkness my old friend\")\n#' @test grepl(\"darkness\", .)\n#' \n#' @export\nhello \u003c- function(who) {\n  paste0(\"Hello, \", who, \"!\")\n}\n```\n\nIf you were already using `testthat`, you'll immediately see a new test \ncontext for testing your examples. And if you aren't using `testthat`, then\nyou'll find that your tests are being run with your examples when you run\n`R CMD check`\n\n## `roxygen2` tags\n\n### `@test`\n\nwill check that the result of the last example is identical to  your test. You\ncan use the example output in a function using a `.`.\n\n```r\n#' @examples\n#' sum(1:10)\n#' @test 55\n#' @test is.numeric(.)\n```\n\n### `@testthat` \n\nis similar, but has the added benefit of automatically inserting a `.` into\n`testthat::expect_*` functions.\n\n```r\n#' @examples\n#' sum(1:10)\n#' @testthat expect_equal(55)\n#' @testthat expect_vector(numeric())\n```\n\n## Prior Art\n\n- [`roxytest`](https://github.com/mikldk/roxytest)\n  A slightly different approach. Allows tests to be written in-line, but\n  generates test files used directly by a testing framework.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgkf%2Ftestex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgkf%2Ftestex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgkf%2Ftestex/lists"}