title: How to move tests into a separate file for binaries in Rust's Cargo?
body: <p>I created a new binary using Cargo:</p>
  
  <pre><code>cargo new my_binary --bin
  </code></pre>
  
  <p>A function in <code>my_binary/src/main.rs</code> can be used for a test:</p>
  
  <pre><code>fn function_from_main() {
      println!("Test OK");
  }
  
  #[test]
  fn my_test() {
      function_from_main();
  }
  </code></pre>
  
  <p>And <code>cargo test -- --nocapture</code> runs the test as expected.</p>
  
  <p>What's the most straightforward way to move this test into a separate file, (keeping <code>function_from_main</code> in <code>my_binary/src/main.rs</code>)?</p>
  
  <p>I tried to do this but am not sure how to make <code>my_test</code> call <code>function_from_main</code> from a separate file.</p>