Discussion:
[rust-dev] A shiny test framework
Vladimir Pouzanov
2014-07-22 19:06:37 UTC
Permalink
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.

This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.

Here's how shiny looks:

#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}

it "is awesome" {
assert!(awesome);
}

it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140722/102ee849/attachment.html>
Ilya Dmitrichenko
2014-07-22 19:09:16 UTC
Permalink
Dude, that's pretty much rspec ;) sweet!
Post by Vladimir Pouzanov
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.
This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.
#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}
it "is awesome" {
assert!(awesome);
}
it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
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/20140722/86536217/attachment.html>
Benjamin Gudehus
2014-07-22 19:10:48 UTC
Permalink
Nice to see an RSpec-like test framework and Hamcrest assertions/matchers
for Rust!


On Tue, Jul 22, 2014 at 9:09 PM, Ilya Dmitrichenko <errordeveloper at gmail.com
Post by Ilya Dmitrichenko
Dude, that's pretty much rspec ;) sweet!
Post by Vladimir Pouzanov
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.
This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.
#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}
it "is awesome" {
assert!(awesome);
}
it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
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/20140722/7601c91a/attachment.html>
Vladimir Pouzanov
2014-07-22 19:31:03 UTC
Permalink
One note on why there's no after_each:

You cannot really make sure that the epilogue is being called, so if you
need to do anything after your test case, use RAII in before_each.


On Tue, Jul 22, 2014 at 8:10 PM, Benjamin Gudehus <hastebrot at gmail.com>
Post by Benjamin Gudehus
Nice to see an RSpec-like test framework and Hamcrest assertions/matchers
for Rust!
On Tue, Jul 22, 2014 at 9:09 PM, Ilya Dmitrichenko <
Post by Ilya Dmitrichenko
Dude, that's pretty much rspec ;) sweet!
Post by Vladimir Pouzanov
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.
This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.
#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}
it "is awesome" {
assert!(awesome);
}
it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140722/318fd251/attachment.html>
Nat Pryce
2014-07-23 11:18:01 UTC
Permalink
Could you use RAII to call a lambda?
Post by Vladimir Pouzanov
You cannot really make sure that the epilogue is being called, so if you
need to do anything after your test case, use RAII in before_each.
On Tue, Jul 22, 2014 at 8:10 PM, Benjamin Gudehus <hastebrot at gmail.com>
Post by Benjamin Gudehus
Nice to see an RSpec-like test framework and Hamcrest assertions/matchers
for Rust!
On Tue, Jul 22, 2014 at 9:09 PM, Ilya Dmitrichenko <
Post by Ilya Dmitrichenko
Dude, that's pretty much rspec ;) sweet!
Post by Vladimir Pouzanov
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.
This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.
#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}
it "is awesome" {
assert!(awesome);
}
it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
--
http://www.natpryce.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140723/589e9537/attachment.html>
Nat Pryce
2014-07-23 11:18:39 UTC
Permalink
It's great to see Hamcrest ported to Rust.
Post by Vladimir Pouzanov
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.
This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.
#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}
it "is awesome" {
assert!(awesome);
}
it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
--
http://www.natpryce.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140723/4ae3c193/attachment.html>
Brian Anderson
2014-07-23 17:27:48 UTC
Permalink
Awesome! I'm glad to see people extending Rust's testing infrastructure
with more expressive frameworks (I assume this translates to `#[test]`
fns under the hood?).
Post by Vladimir Pouzanov
I've just published a tiny test framework: shiny at
https://github.com/farcaller/shiny. It's best used with hamcrest-rust.
This library exists because I find it ugly to redefine all the
initialisation code in every test case and I can't simply move it to a
function due to problems with moving [T] out.
#[cfg(test)]
mod test {
describe!(
before_each {
let awesome = true;
}
it "is awesome" {
assert!(awesome);
}
it "injects before_each into all test cases" {
let still_awesome = awesome;
assert!(still_awesome);
}
)
}
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
_______________________________________________
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/20140723/79b8ed6d/attachment.html>
Vladimir Pouzanov
2014-07-23 17:42:48 UTC
Permalink
On Wed, Jul 23, 2014 at 6:27 PM, Brian Anderson <banderson at mozilla.com>
I assume this translates to `#[test]` fns under the hood?
Exactly. That actually complicates `context` support a bit, as shiny needs
to create nested modules. That would require forwarding all the views into
child modules (as they are transparent for end developer).
--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://farcaller.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140723/22391f16/attachment.html>
Loading...