Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Rust Fundamentals

Lesson 27 of 50 · rust

Writing Tests

Duration: 15 minutes

Writing Tests\n\nTests live in the tests directory or inline with #[cfg(test)].\n\nrust\n#[cfg(test)]\nmod tests {\n #[test]\n fn it_works() {\n assert_eq!(2 + 2, 4);\n }\n}\n\n\nRun tests with cargo test.

Previous: Crates.io and PublishingNext: Documentation with Cargo Doc