课程: Google Cloud Professional Machine Learning Engineer Cert Prep

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Demo: Unit testing Rust

Demo: Unit testing Rust

- [Instructor] Here we have a GitHub Codespace where I'm going to build out a unit test for a Rust project to start out with. First, I need to create a new Rust project, so I'll type in cargo new, and we'll call this T Rust as in test Rust. Now, I'll go ahead and cd into this directory. Now, the first thing to keep in mind here in this particular directory is that I only have a main file to start with, so I'm going to need to create a structure for my tests and also for my library code. so first up what I'll do is I will make a directory called tests and this is where I'm going to put in my tests and I'm going to go ahead and create an empty test file there. so we'll say touch test, and we'll call this testlib.rs. Also, I'll need to create my library file. so I'll go ahead and say, touchsrclib.rs. Perfect, and if I go through here and I refresh this you'll see the new structure. and in fact, I can also type in tree and…

内容