Skip to content
Permalink
Browse files

Add deprecation notices to old testing posts and specify requirements

  • Loading branch information...
phil-opp committed Apr 27, 2019
1 parent 9995c69 commit a8865e2277079cb0a6c9fa72eb87faa9f06abc40
@@ -4,6 +4,9 @@ weight = 4
path = "unit-testing"
date = 2018-04-29

[extra]
warning_short = "Deprecated: "
warning = "This post is deprecated in favor of the [_Testing_](/testing) post and will no longer receive updates."
+++

This post explores unit testing in `no_std` executables using Rust's built-in test framework. We will adjust our code so that `cargo test` works and add some basic unit tests to our VGA buffer module.
@@ -20,7 +23,13 @@ This blog is openly developed on [GitHub]. If you have any problems or questions

## Requirements

In this post we explore how to execute `cargo test` on the host system. This only works if you don't have a default target set in your `.cargo/config` file. If you don't have a `.cargo/config` file in your project, you're fine too.
In this post we explore how to execute `cargo test` on the host system (as a normal Linux/Windows/macOS executable). This only works if you don't have a `.cargo/config` file that sets a default target. If you followed the [_Minimal Rust Kernel_] post before 2019-04-27, you should be fine. If you followed it after that date, you need to remove the `build.target` key from your `.cargo/config` file and explicitly pass a target argument to `cargo xbuild`.

[_Minimal Rust Kernel_]: ./second-edition/posts/02-minimal-rust-kernel/index.md

Alternatively, consider reading the new [_Testing_] post instead. It sets up a similar functionality as this post, but instead of running the tests on your host system, they are run in a realistic environment inside QEMU.

[_Testing_]: ./second-edition/posts/04-testing/index.md

## Unit Tests for `no_std` Binaries
Rust has a [built-in test framework] that is capable of running unit tests without the need to set anything up. Just create a function that checks some results through assertions and add the `#[test]` attribute to the function header. Then `cargo test` will automatically find and execute all test functions of your crate.
@@ -4,6 +4,9 @@ weight = 5
path = "integration-tests"
date = 2018-06-15

[extra]
warning_short = "Deprecated: "
warning = "This post is deprecated in favor of the [_Testing_](/testing) post and will no longer receive updates."
+++

To complete the testing picture we implement a basic integration test framework, which allows us to run tests on the target system. The idea is to run tests inside QEMU and report the results back to the host through the serial port.
@@ -18,6 +21,13 @@ This blog is openly developed on [GitHub]. If you have any problems or questions

<!-- toc -->

## Requirements

This post builds upon the [_Unit Testing_] post, so you need to follow it first. Alternatively, consider reading the new [_Testing_] post instead, which replaces both _Unit Testing_ and this post. The new posts implements similar functionality, but integrates it directly in `cargo xtest`, so that both unit and integration tests run in a realistic environment inside QEMU.

[_Unit Testing_]: ./second-edition/posts/deprecated/04-unit-testing/index.md
[_Testing_]: ./second-edition/posts/04-testing/index.md

## Overview

In the previous post we added support for unit tests. The goal of unit tests is to test small components in isolation to ensure that each of them works as intended. The tests are run on the host machine and thus shouldn't rely on architecture specific functionality.

0 comments on commit a8865e2

Please sign in to comment.
You can’t perform that action at this time.