tests/testthat/test-service.R

# Test `Service` interface.

test_that("'Service' interface cannot be instantiated", {
    # Create a mock object that has the `Service` class.
    assign("object", "Mock Service", envir = environment())

    # Assign a class to the mock service object.
    class(object) <- "Service"

    # Expect an error upon instantiation.
    expect_error(
        Service$new(),
        as_text(Exception$abstract_class_not_instantiable(object))
    )
})


test_that("'Service' interface methods throw errors", {
    # Create an improper service implementation.
    service <- ServiceImplementation$new()

    # Expect unimplemented service methods to throw errors.
    tests_set_for_unimplemented_service_methods(service)
})

Try the parabar package in your browser

Any scripts or data that you put into this service are public.

parabar documentation built on May 29, 2024, 8:42 a.m.