• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 import static org.junit.Assert.assertEquals;
2 import static org.junit.Assert.assertTrue;
3 
4 import com.google.devtools.build.runfiles.AutoBazelRepository;
5 import com.google.devtools.build.runfiles.Runfiles;
6 import java.io.IOException;
7 import java.nio.file.Files;
8 import java.nio.file.Path;
9 import java.nio.file.Paths;
10 import mypackage.MyLib;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.junit.runners.JUnit4;
14 
15 @RunWith(JUnit4.class)
16 @AutoBazelRepository
17 public class MyTest {
18   @Test
main()19   public void main() {
20     assertEquals(MyLib.myStr(), "my_string");
21   }
22 
23   @Test
runfiles()24   public void runfiles() throws IOException {
25     Runfiles runfiles = Runfiles.preload().withSourceRepository(AutoBazelRepository_MyTest.NAME);
26     Path path = Paths.get(runfiles.rlocation("integration_test_repo/src/data.txt"));
27     assertTrue(Files.exists(path));
28   }
29 }
30