Skip to content

Commit

Permalink
Add Hello World explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jun 29, 2024
1 parent 0a84c36 commit 226d446
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 22 deletions.
8 changes: 4 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
rjcbilderbeek@gmail.com.
<rjcbilderbeek@gmail.com>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Here we discuss how to contribute:

Spoken text suggestions are ideas, feedback, etc. and are written in English.

For ideas or feedback,
For ideas or feedback,
create an [Issue](https://github.com/richelbilderbeek/bevy_tdd_book/issues).
These Issues will be discussed publicly in that Issue
and will help shape the development of the book.
Expand All @@ -21,13 +21,13 @@ and will help shape the development of the book.

Book text suggestions are suggested textual changes to the book.

To suggest these, either
To suggest these, either
create an [Issue](https://github.com/richelbilderbeek/bevy_tdd_book/issues)
or submit a Pull Request.

These Issues and Pull Requests will be discussed publicly
and accepted if they are judged to improve the book.
Of course, 'to improve the book' is subjective.
Of course, 'to improve the book' is subjective.

Here are things that are likely to be accepted:

Expand All @@ -44,13 +44,13 @@ Here are things that are unlikely to be accepted:

Code suggestions are suggested changes to the Rust code.

To suggest these, either
To suggest these, either
create an [Issue](https://github.com/richelbilderbeek/bevy_tdd_book/issues)
or submit a Pull Request.

These Issues and Pull Requests will be discussed publicly
and accepted if they are judged to improve the code.
Of course, 'to improve the code' is subjective.
Of course, 'to improve the code' is subjective.

Here are things that are likely to be accepted:

Expand All @@ -60,4 +60,4 @@ Here are things that are unlikely to be accepted:

- Anything that breaks a continuous integration test
- Anything that reduces code coverage below 100%
- Using a faster, yet less readable alternative
- Using a faster, yet less readable alternative
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Filename |Descriptions

## Footnotes

* [1] 'book' is an overstatement for now: it is just a collection of notes
* [2] There is no chapter numbering yet
* [1] 'book' is an overstatement for now: it is just a collection of notes
* [2] There is no chapter numbering yet

## Links

* [Blog post 'Test-Driven Development in Rust Game Development with Bevy' by Edgardo Carreras](https://edgardocarreras.com/blog/tdd-in-rust-game-engine-bevy/)
* [Blog post 'Test-Driven Development in Rust Game Development with Bevy' by Edgardo Carreras](https://edgardocarreras.com/blog/tdd-in-rust-game-engine-bevy/)
2 changes: 1 addition & 1 deletion add_player.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ This chapter shows how to add a player to a game.

## Links

* [https://github.com/richelbilderbeek/bevy_tdd_book_add_player](https://github.com/richelbilderbeek/bevy_tdd_book_add_player)
* [https://github.com/richelbilderbeek/bevy_tdd_book_add_player](https://github.com/richelbilderbeek/bevy_tdd_book_add_player)
12 changes: 6 additions & 6 deletions faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ This book tries to start from scratch and build up gradually.
## What is the intended audience of this book?

Intermediate Rust developers: people that have read parts of
'The Rust programming language' [Klabnik & Nichols, 2018][Klabnik & Nichols, 2023].
'The Rust programming language' `[Klabnik & Nichols, 2018]``[Klabnik & Nichols, 2023]`.

This book does not teach Rust, nor Bevy.
This book does not teach Rust, nor Bevy.
Instead, it shows Test-Driven Development in Rust with Bevy.

## What is the goal of this book?

The goal is to demonstrate how to do Test-Driven Development ('TDD')
The goal is to demonstrate how to do Test-Driven Development ('TDD')
in Rust with Bevy.

## What are the subgoals of this book?

* Always achieve 100% code coverage when ignoring
* Always achieve 100% code coverage when ignoring
the `main` function in `src/main.rs`.

## What are the non-goals of this book?
Expand All @@ -38,7 +38,7 @@ TDD needs tests that do not require user input.

## References

* [Klabnik & Nichols, 2018] Klabnik, Steve, and Carol Nichols.
* `[Klabnik & Nichols, 2018]` Klabnik, Steve, and Carol Nichols.
The Rust programming language. No Starch Press, 2023.
* [Klabnik & Nichols, 2023] Klabnik, Steve, and Carol Nichols.
* `[Klabnik & Nichols, 2023]` Klabnik, Steve, and Carol Nichols.
The Rust programming language. No Starch Press, 2023.
52 changes: 51 additions & 1 deletion hello_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,59 @@

This chapter is a minimal Bevy program.

The minimal program will create a Bevy `App`
and then run it ([main.rs](https://github.com/richelbilderbeek/bevy_tdd_book_hello_world/blob/master/src/main.rs)):

Check failure on line 6 in hello_world.md

View workflow job for this annotation

GitHub Actions / check_markdown

Trailing spaces [Expected: 0 or 2; Actual: 1]

```rust
use crate::app::create_app;
mod app;

fn main() {
let mut app = create_app();
app.run();
}
```

The `main` function will not be used in automated testing,
as it starts our game: starting the game

Check failure on line 19 in hello_world.md

View workflow job for this annotation

GitHub Actions / check_markdown

Trailing spaces [Expected: 0 or 2; Actual: 1]
will require that a user needs to do something to close it.
Hence, the `main` function 'just' runs the `App`.

The testing takes place in the `create_app` function.
The first two lines of `main.rs` allow us to call the `create_app`
function in the file [app.rs](https://github.com/richelbilderbeek/bevy_tdd_book_hello_world/blob/master/src/app.rs).

Our first trivial test will be if `create_app` does something,
i.e. it does not crash:

```

Check failure on line 30 in hello_world.md

View workflow job for this annotation

GitHub Actions / check_markdown

Fenced code blocks should have a language specified [Context: "```"]
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_can_create_app() {
create_app();
}
}
```

Writing this test will break the code, as the function `create_app`
does not exist yet.

Here is the `create_app` function definition that fixes all tests:

```rust
use bevy::prelude::*;

pub fn create_app() -> App {
return App::new();
}
```

The full code of [app.rs](https://github.com/richelbilderbeek/bevy_tdd_book_hello_world/blob/master/src/app.rs)
can be found at [app.rs](https://github.com/richelbilderbeek/bevy_tdd_book_hello_world/blob/master/src/app.rs).

## Links

* [https://github.com/richelbilderbeek/bevy_tdd_book_hello_world](https://github.com/richelbilderbeek/bevy_tdd_book_hello_world)
* [https://github.com/richelbilderbeek/bevy_tdd_book_hello_world](https://github.com/richelbilderbeek/bevy_tdd_book_hello_world)

0 comments on commit 226d446

Please sign in to comment.