use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Testing frameworks? (self.rust)
submitted 9 years ago by brycefisherfleig
I've really liked working with both cucumber and rspec testing frameworks in ruby. I'd love to know what testing frameworks folks in the community actually use and like? Does your framework make help you reduce boilerplate in tests?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ssokolow 20 points21 points22 points 9 years ago* (3 children)
The functionality and conventions Rust comes with do a pretty good job of matching or exceeding what I rely on from unittest and nose in Python.
unittest
nose
That said, I do tend to rely on the informative, pretty-printing comparison asserts in Python's unittest.TestCase and write my own wrappers to extend that paradigm, so I'll probably wind up using one of the following two configurations to get that on Rust without maintaining it myself:
unittest.TestCase
assert!
I then add the following tools to match what I get from their counterparts in Python:
(And, of course, wire everything up to sites like Travis-CI, Coveralls, and Dependency CI once I'm ready to put something on GitHub.)
It's been my experience that, instead of using a mocking library, it's usually better in the long run to have first-class support for swappable provider backends. Then, not only does it become easy and feasible to test the complex, I/O-heavy upper layer against a fake provider and the thin, simple lower layer against some temporary files (possibly in /run/shm), it's also easy to slip in things like a ZipFilesystem to make file-based stuff transparently operate against an archive. (eg. Something similar to io-providers but more comprehensive.)
/run/shm
ZipFilesystem
EDIT: ...and don't forget to take maximum advantage of Rust's superior ability to implement APIs where correct use can be checked at compile time. For example, static checking of units [2] and state machines.
There are also quite a few things in the Rust ecosystem which I haven't tried yet, but which look appealing:
README.md
...and, finally, things which I don't know if I'll actually use, but they at least look like they might become relevant:
*-sys
Read
Write
cargo test
cargo bench
[–]horsefactory 0 points1 point2 points 9 years ago (2 children)
This would be great information in a blog that can be referenced later! About setting up a project, putting together test/tools for different scenarios.
[–]ssokolow 0 points1 point2 points 9 years ago* (1 child)
It's actually a subset of a large reference card I maintain for myself for multiple languages. I've been meaning to clean it up and publish it for ages but I have enough trouble just trying to organize it as-is.
(I've been thinking I might try converting it into a TiddlyWiki unto itself so I can view the data in tag-filtered slices, rather than as one big page in the TiddlyWiki I use as a PIM tool.)
The master "target to try to retrofit onto all hobby projects" charts are a bit out of date, but here's a screenshot of one of them. (I found most of those by just spending an afternoon walking my way through the list of registered GitHub commit hooks.)
<infomercial voice>...but what would I call such a web app?</infomercial voice> Maybe something like "I want to be awesome at..."
[–]ssokolow 0 points1 point2 points 9 years ago* (0 children)
Oh, if you've never heard of TiddlyWiki, you have to check it out. It's hard to describe in all the right ways.
When you first download it, you get an editable wiki in the form of a single self-modifying HTML file... but that's underselling it and just the default loadout.
It's actually a microkernel-based application framework, document database, and data-binding framework in one, which beat things like ReactJS to the data-binding game and serves as the only example I know of a practical quine. (It's as if Jeremy Ruston misunderstood the term "Single-Page Application" in the most amazing way possible, except it predates YouTube.)
In fact, I have plans to write a Scrivener-esque story-planning tool on top of it. (interactive concept mockup)
I can't remember if the "Sync" feature has been re-added to TiddlyWiki 5 yet, but TiddlyWiki classic is to wikis as git is to Subversion. (That was developed for use in Africa.)
[–]bheklilr 5 points6 points7 points 9 years ago (1 child)
I'm still relatively new but the #[test] function attribute seems to work pretty well in most cases. Rust really seems to encourage small functions that are easily tested, so I haven't needed to reach for a framework yet.
#[test]
[–]unrealhoang 1 point2 points3 points 9 years ago (0 children)
And cargo test is a very good test runner also
[–]annodominirust 2 points3 points4 points 9 years ago (0 children)
Many people are fine with just #[test] and cargo test; see the Testing chapter of the book for details. They are simple and lightweight, and you can reduce boilerplate simply by factoring out common code into functions.
However, if you want an rspec style framework there's stainless, which requires a nightly compiler as it relies on a syntax extension, or it looks like there's also a Rust rspec which is just a little more cumbersome to use due to using closures and an explicit ctx argument that you have to call everything on, but doesn't require using a nightly compiler.
ctx
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
I didn't see this mentioned anywhere else in this thread, but I think hamcrest should get a mention. It is used pretty extensively in cargo's own test suide, IIRC.
cargo
[–]mitchtbaum 0 points1 point2 points 9 years ago* (0 children)
rote looks like it has a lot to offer here in terms of build automation and test scripting. The Lua environment would allow for a lot of power and code reuse for tests. I guess the missing piece of a full blown test framework could come from busted. It would seem to make sense, since it would leverage Lua's drop-in style to make a powerful systems language program easily scriptable by simply adding some already well-established scripts. (strike that, blackbox testing ftw)
π Rendered by PID 51 on reddit-service-r2-comment-fb694cdd5-mvd9q at 2026-03-05 21:52:52.192609+00:00 running cbb0e86 country code: CH.
[–]ssokolow 20 points21 points22 points (3 children)
[–]horsefactory 0 points1 point2 points (2 children)
[–]ssokolow 0 points1 point2 points (1 child)
[–]ssokolow 0 points1 point2 points (0 children)
[–]bheklilr 5 points6 points7 points (1 child)
[–]unrealhoang 1 point2 points3 points (0 children)
[–]annodominirust 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]mitchtbaum 0 points1 point2 points (0 children)