[rust-dev] rust unit testing

David Siefert siefert.david at gmail.com
Sat Mar 2 07:39:06 PST 2013


Wow--thanks for everyone responding so quickly and helping out!
This solves my problem--how can I update the documentation for at least
version 0.5?

Thanks,
David


On Sat, Mar 2, 2013 at 6:46 AM, Niko Matsakis <niko at alum.mit.edu> wrote:

> You need to include "extern mod std;" at the top of your program.  This
> will link in the standard library (as opposed to the core lib).  I think
> that in modern versions of the compiler (i.e., the trunk) this is
> automatic, or at least has a better error message, but I am not sure.
>
>
> Niko
>
>   David Siefert <siefert.david at gmail.com>
>  March 2, 2013 12:10 AM
> Hi,
>
> I'm trying to get started with rust 0.5.  I've got it built and can
> compile+execute some simple programs.  Now I want to get running with test
> driven development, so I just want to write, build, and run a simple unit
> test... according to the documentation+wiki, the following is the minimal
> unit test:
>
> $ cat test.rs
> // sample
> #[test]
> fn testFail() {
>     fail;
> }
>
> And the --test option is supposed to build a harness to run everything
> marked with attribute #[test]:
>
> $ rustc test.rs --test
> test.rs:1:0: 1:0 error: unresolved name
> test.rs:1 // sample
>           ^
> test.rs:1:0: 1:0 error: use of undeclared module `std::test`
> test.rs:1 // sample
>           ^
> test.rs:1:0: 1:0 error: unresolved name: std::test::test_main
> test.rs:1 // sample
>           ^
> test.rs:1:0: 1:0 error: unresolved name
> test.rs:1 // sample
>           ^
> test.rs:1:0: 1:0 error: use of undeclared module `std::test`
> test.rs:1 // sample
>           ^
> test.rs:1:0: 1:0 error: use of undeclared type name `std::test::TestDesc`
> test.rs:1 // sample
>           ^
> Can someone point me in the right direction here?
>
> Thanks,
> David
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130302/a77898b6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130302/a77898b6/attachment-0001.jpg>


More information about the Rust-dev mailing list