[build][rust] Switch Rust test deps to _test targets, enable testonly

Closes BLD-492.

Change-Id: I97bc7ed578f1e3c1bfce604de8a1a2dc7d671f49
diff --git a/build/rust/rustc_artifact.gni b/build/rust/rustc_artifact.gni
index 0b73466..9e33469 100644
--- a/build/rust/rustc_artifact.gni
+++ b/build/rust/rustc_artifact.gni
@@ -491,8 +491,6 @@
 
   if (with_unit_tests) {
     action(build_test_target_name) {
-      forward_variables_from(invoker, [ "testonly" ])
-
       script = rustc_target_script
       pool = rustc_target_pool
 
@@ -510,7 +508,7 @@
         test_output_file,
       ]
 
-      # TODO(tmandry): Add `testonly = true` here once tests only depend on the test group.
+      testonly = true
       depfile = test_depfile
       deps = rustc_target_deps
       if (is_linux || is_mac) {
@@ -627,8 +625,7 @@
     test_output_path = "${root_out_dir}/${test_filename}"
 
     copy_with_build_id(strip_test_target_name) {
-      forward_variables_from(invoker, [ "testonly" ])
-
+      testonly = true
       deps = [
         ":${build_test_target_name}",
       ]
@@ -704,12 +701,13 @@
   if (with_unit_tests) {
     test_target_name = "${target_name}_test"
     group(test_target_name) {
-      forward_variables_from(invoker, [ "testonly" ])
+      testonly = true
       public_deps = test_group_deps
     }
 
-    # TODO(tmandry): Remove this once we have everyone depending on the right group.
-    group_deps += [ ":${test_target_name}" ]
+    if (only_unit_tests) {
+      group_deps += [ ":${test_target_name}" ]
+    }
   }
 
   group(target_name) {
diff --git a/build/rust/rustc_staticlib.gni b/build/rust/rustc_staticlib.gni
index 922d9a0..82ba7ac 100644
--- a/build/rust/rustc_staticlib.gni
+++ b/build/rust/rustc_staticlib.gni
@@ -110,4 +110,14 @@
       ":$rustc_target",
     ]
   }
+
+  if (defined(invoker.with_unit_tests) && invoker.with_unit_tests) {
+    test_target_name = "${target_name}_test"
+    group(test_target_name) {
+      testonly = true
+      public_deps = [
+        ":${rustc_target}_test",
+      ]
+    }
+  }
 }
diff --git a/examples/hello_world/rust/BUILD.gn b/examples/hello_world/rust/BUILD.gn
index 95bc9a9..3de589d 100644
--- a/examples/hello_world/rust/BUILD.gn
+++ b/examples/hello_world/rust/BUILD.gn
@@ -55,7 +55,7 @@
 
 test_package("hello_world_rust_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
   tests = [
     {
diff --git a/examples/isolated_cache/BUILD.gn b/examples/isolated_cache/BUILD.gn
index 8d87cd1..1c4492f 100644
--- a/examples/isolated_cache/BUILD.gn
+++ b/examples/isolated_cache/BUILD.gn
@@ -54,7 +54,7 @@
 
 test_package("isolated_cache_example_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
   tests = [
     {
diff --git a/examples/rust_static_linking/BUILD.gn b/examples/rust_static_linking/BUILD.gn
index e9f95fe..fbab5d8 100644
--- a/examples/rust_static_linking/BUILD.gn
+++ b/examples/rust_static_linking/BUILD.gn
@@ -21,7 +21,7 @@
 
 unittest_package("static_linking_tests") {
   deps = [
-    ":static_linking",
+    ":static_linking_test",
   ]
   tests = [
     {
diff --git a/garnet/bin/archivist/BUILD.gn b/garnet/bin/archivist/BUILD.gn
index f3c20ba..ae0f34d 100644
--- a/garnet/bin/archivist/BUILD.gn
+++ b/garnet/bin/archivist/BUILD.gn
@@ -56,7 +56,7 @@
 
 test_package("archivist_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/device_settings/BUILD.gn b/garnet/bin/device_settings/BUILD.gn
index f28ae6c..5458390 100644
--- a/garnet/bin/device_settings/BUILD.gn
+++ b/garnet/bin/device_settings/BUILD.gn
@@ -54,7 +54,7 @@
 
 unittest_package("device_settings_manager_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/fonts/BUILD.gn b/garnet/bin/fonts/BUILD.gn
index 10ce92d..b202337 100644
--- a/garnet/bin/fonts/BUILD.gn
+++ b/garnet/bin/fonts/BUILD.gn
@@ -100,8 +100,8 @@
 
 test_package("font_provider_tests") {
   deps = [
-    ":font_provider_test",
-    ":font_server",
+    ":font_provider_test_test",
+    ":font_server_test",
   ]
 
   tests = [
diff --git a/garnet/bin/kms/BUILD.gn b/garnet/bin/kms/BUILD.gn
index e34b284..3d5e9fb 100644
--- a/garnet/bin/kms/BUILD.gn
+++ b/garnet/bin/kms/BUILD.gn
@@ -55,7 +55,7 @@
 
 test_package("kms_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
   tests = [
     {
diff --git a/garnet/bin/log_listener/BUILD.gn b/garnet/bin/log_listener/BUILD.gn
index 0897e4a..7ba2ca9 100644
--- a/garnet/bin/log_listener/BUILD.gn
+++ b/garnet/bin/log_listener/BUILD.gn
@@ -73,7 +73,7 @@
 
 test_package("log_listener_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/logger/BUILD.gn b/garnet/bin/logger/BUILD.gn
index a88fff9e..6baf50d 100644
--- a/garnet/bin/logger/BUILD.gn
+++ b/garnet/bin/logger/BUILD.gn
@@ -48,7 +48,7 @@
 
 test_package("logger_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/logger/tests/BUILD.gn b/garnet/bin/logger/tests/BUILD.gn
index 4f7aac4..408c2d2 100644
--- a/garnet/bin/logger/tests/BUILD.gn
+++ b/garnet/bin/logger/tests/BUILD.gn
@@ -19,7 +19,7 @@
   deps = [
     "cpp:logger_integration_cpp_tests",
     "go/src:logger_integration_go_tests",
-    "rust:bin",
+    "rust:bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/netcfg/BUILD.gn b/garnet/bin/netcfg/BUILD.gn
index 1eec280..0102863 100644
--- a/garnet/bin/netcfg/BUILD.gn
+++ b/garnet/bin/netcfg/BUILD.gn
@@ -78,7 +78,7 @@
 
 test_package("netcfg_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
   tests = [
     {
diff --git a/garnet/bin/odu/BUILD.gn b/garnet/bin/odu/BUILD.gn
index 9d9e72f..d5c9f17 100644
--- a/garnet/bin/odu/BUILD.gn
+++ b/garnet/bin/odu/BUILD.gn
@@ -51,7 +51,7 @@
 
 test_package("odu_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
   tests = [
     {
diff --git a/garnet/bin/omaha_client/BUILD.gn b/garnet/bin/omaha_client/BUILD.gn
index 4bac9a7..1cba9e7 100644
--- a/garnet/bin/omaha_client/BUILD.gn
+++ b/garnet/bin/omaha_client/BUILD.gn
@@ -57,7 +57,7 @@
 
 test_package("omaha_client_service_bin_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/pkg_cache/BUILD.gn b/garnet/bin/pkg_cache/BUILD.gn
index fbe766b..2fb2ced 100644
--- a/garnet/bin/pkg_cache/BUILD.gn
+++ b/garnet/bin/pkg_cache/BUILD.gn
@@ -48,7 +48,7 @@
 
 test_package("pkg_cache_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/pkg_ctl/BUILD.gn b/garnet/bin/pkg_ctl/BUILD.gn
index 79e8ec2..73732fc 100644
--- a/garnet/bin/pkg_ctl/BUILD.gn
+++ b/garnet/bin/pkg_ctl/BUILD.gn
@@ -53,7 +53,7 @@
 
 test_package("pkg_ctl_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/pkg_resolver/BUILD.gn b/garnet/bin/pkg_resolver/BUILD.gn
index b94ba7b..8fdcd08 100644
--- a/garnet/bin/pkg_resolver/BUILD.gn
+++ b/garnet/bin/pkg_resolver/BUILD.gn
@@ -61,7 +61,7 @@
 
 test_package("pkg_resolver_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/rolldice/BUILD.gn b/garnet/bin/rolldice/BUILD.gn
index a8d7e9d..82340a8 100644
--- a/garnet/bin/rolldice/BUILD.gn
+++ b/garnet/bin/rolldice/BUILD.gn
@@ -49,7 +49,7 @@
 
 unittest_package("rolldice-tests") {
   deps = [
-    ":lib",
+    ":lib_test",
   ]
 
   tests = [
diff --git a/garnet/bin/setui/BUILD.gn b/garnet/bin/setui/BUILD.gn
index 897e634..8c2663b 100644
--- a/garnet/bin/setui/BUILD.gn
+++ b/garnet/bin/setui/BUILD.gn
@@ -57,7 +57,7 @@
 
 unittest_package("setui_service_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/setui_client/BUILD.gn b/garnet/bin/setui_client/BUILD.gn
index 003771b..4f908a37 100644
--- a/garnet/bin/setui_client/BUILD.gn
+++ b/garnet/bin/setui_client/BUILD.gn
@@ -46,7 +46,7 @@
 
 unittest_package("setui_client_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/sl4f/BUILD.gn b/garnet/bin/sl4f/BUILD.gn
index e443491..f722b13f 100644
--- a/garnet/bin/sl4f/BUILD.gn
+++ b/garnet/bin/sl4f/BUILD.gn
@@ -80,7 +80,7 @@
 
 unittest_package("sl4f-tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/stash/BUILD.gn b/garnet/bin/stash/BUILD.gn
index 94ae1e7..4b19869 100644
--- a/garnet/bin/stash/BUILD.gn
+++ b/garnet/bin/stash/BUILD.gn
@@ -55,7 +55,7 @@
 
 test_package("stash_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/stash_ctl/BUILD.gn b/garnet/bin/stash_ctl/BUILD.gn
index 6b6a4f4..b8b9a22 100644
--- a/garnet/bin/stash_ctl/BUILD.gn
+++ b/garnet/bin/stash_ctl/BUILD.gn
@@ -55,7 +55,7 @@
 
 test_package("stash_ctl_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/terminal/BUILD.gn b/garnet/bin/terminal/BUILD.gn
index 2a42ce7..db94ea3 100644
--- a/garnet/bin/terminal/BUILD.gn
+++ b/garnet/bin/terminal/BUILD.gn
@@ -61,7 +61,7 @@
 
 test_package("terminal_tests") {
   deps = [
-    "third_party/term-model",
+    "third_party/term-model:term-model_test",
   ]
   tests = [
     {
diff --git a/garnet/bin/ui/BUILD.gn b/garnet/bin/ui/BUILD.gn
index 252d4fa..5ace26c 100644
--- a/garnet/bin/ui/BUILD.gn
+++ b/garnet/bin/ui/BUILD.gn
@@ -159,7 +159,7 @@
 
 test_package("ime_service_tests") {
   deps = [
-    "ime",
+    "ime:ime_test",
     "//garnet/bin/ui/text/test_suite:test_suite",
   ]
 
diff --git a/garnet/bin/ui/text/default_hardware_ime/BUILD.gn b/garnet/bin/ui/text/default_hardware_ime/BUILD.gn
index 53fe32c..9ed589c 100644
--- a/garnet/bin/ui/text/default_hardware_ime/BUILD.gn
+++ b/garnet/bin/ui/text/default_hardware_ime/BUILD.gn
@@ -57,7 +57,7 @@
   ]
 
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/garnet/bin/ui/text/test_suite/BUILD.gn b/garnet/bin/ui/text/test_suite/BUILD.gn
index 4352674..e903ec1 100644
--- a/garnet/bin/ui/text/test_suite/BUILD.gn
+++ b/garnet/bin/ui/text/test_suite/BUILD.gn
@@ -48,7 +48,7 @@
 
 test_package("text_test_suite_tests") {
   deps = [
-    ":test_suite",
+    ":test_suite_test",
   ]
 
   tests = [
diff --git a/garnet/bin/vsock_service/BUILD.gn b/garnet/bin/vsock_service/BUILD.gn
index 2adf736..dfb921d 100644
--- a/garnet/bin/vsock_service/BUILD.gn
+++ b/garnet/bin/vsock_service/BUILD.gn
@@ -65,7 +65,7 @@
 
 test_package("vsock_service-tests") {
   deps = [
-    ":lib",
+    ":lib_test",
   ]
 
   tests = [
diff --git a/garnet/bin/wayland/core/BUILD.gn b/garnet/bin/wayland/core/BUILD.gn
index 4319784..f77d33e 100644
--- a/garnet/bin/wayland/core/BUILD.gn
+++ b/garnet/bin/wayland/core/BUILD.gn
@@ -22,7 +22,8 @@
 }
 
 group("tests") {
+  testonly = true
   public_deps = [
-    ":core",
+    ":core_test",
   ]
 }
diff --git a/garnet/examples/intl/manager/BUILD.gn b/garnet/examples/intl/manager/BUILD.gn
index 6ca0951..ed0f787 100644
--- a/garnet/examples/intl/manager/BUILD.gn
+++ b/garnet/examples/intl/manager/BUILD.gn
@@ -49,7 +49,7 @@
 
 test_package("intl_property_manager_tests") {
   deps = [
-    ":intl_property_manager_bin",
+    ":intl_property_manager_bin_test",
   ]
 
   tests = [
diff --git a/garnet/examples/rust/testing/BUILD.gn b/garnet/examples/rust/testing/BUILD.gn
index 95a5f7f..462532d 100644
--- a/garnet/examples/rust/testing/BUILD.gn
+++ b/garnet/examples/rust/testing/BUILD.gn
@@ -28,8 +28,9 @@
 }
 
 group("testing-tests") {
+  testonly = true
   public_deps = [
-    ":testing",
+    ":testing_test",
     ":testing_integration_test",
     ":testing_integration_test_two",
   ]
diff --git a/garnet/lib/rust/cm_fidl_translator/BUILD.gn b/garnet/lib/rust/cm_fidl_translator/BUILD.gn
index 079fe6c..2712ba4 100644
--- a/garnet/lib/rust/cm_fidl_translator/BUILD.gn
+++ b/garnet/lib/rust/cm_fidl_translator/BUILD.gn
@@ -26,7 +26,7 @@
 
 test_package("cm_fidl_translator_tests") {
   deps = [
-    ":cm_fidl_translator",
+    ":cm_fidl_translator_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/cm_fidl_validator/BUILD.gn b/garnet/lib/rust/cm_fidl_validator/BUILD.gn
index 3e1ff3f..91dc868 100644
--- a/garnet/lib/rust/cm_fidl_validator/BUILD.gn
+++ b/garnet/lib/rust/cm_fidl_validator/BUILD.gn
@@ -18,7 +18,7 @@
 
 test_package("cm_fidl_validator_tests") {
   deps = [
-    ":cm_fidl_validator",
+    ":cm_fidl_validator_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/cm_json/BUILD.gn b/garnet/lib/rust/cm_json/BUILD.gn
index 51368cf..182706e 100644
--- a/garnet/lib/rust/cm_json/BUILD.gn
+++ b/garnet/lib/rust/cm_json/BUILD.gn
@@ -31,7 +31,7 @@
 
 test_package("cm_json_tests") {
   deps = [
-    ":cm_json",
+    ":cm_json_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/cm_rust/BUILD.gn b/garnet/lib/rust/cm_rust/BUILD.gn
index c6944e1..e5e9a23 100644
--- a/garnet/lib/rust/cm_rust/BUILD.gn
+++ b/garnet/lib/rust/cm_rust/BUILD.gn
@@ -19,7 +19,7 @@
 
 test_package("cm_rust_tests") {
   deps = [
-    ":cm_rust",
+    ":cm_rust_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/connectivity-testing/BUILD.gn b/garnet/lib/rust/connectivity-testing/BUILD.gn
index d13e65b..fa51c39 100644
--- a/garnet/lib/rust/connectivity-testing/BUILD.gn
+++ b/garnet/lib/rust/connectivity-testing/BUILD.gn
@@ -29,7 +29,7 @@
 
 unittest_package("connectivity-testing-tests") {
   deps = [
-    ":connectivity-testing",
+    ":connectivity-testing_test",
   ]
   tests = [
     {
diff --git a/garnet/lib/rust/escaped-cstring/BUILD.gn b/garnet/lib/rust/escaped-cstring/BUILD.gn
index f480289..627f28f 100644
--- a/garnet/lib/rust/escaped-cstring/BUILD.gn
+++ b/garnet/lib/rust/escaped-cstring/BUILD.gn
@@ -21,7 +21,7 @@
 
 test_package("escaped-cstring-tests") {
   deps = [
-    ":escaped-cstring",
+    ":escaped-cstring_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/ethernet/BUILD.gn b/garnet/lib/rust/ethernet/BUILD.gn
index ad80e9c..5209f99 100644
--- a/garnet/lib/rust/ethernet/BUILD.gn
+++ b/garnet/lib/rust/ethernet/BUILD.gn
@@ -28,7 +28,7 @@
 
 unittest_package("ethernet-tests") {
   deps = [
-    ":ethernet",
+    ":ethernet_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/fidl_fuchsia_amber_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_amber_ext/BUILD.gn
index c7dae72..3d6be18 100644
--- a/garnet/lib/rust/fidl_fuchsia_amber_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_amber_ext/BUILD.gn
@@ -25,7 +25,7 @@
 
 test_package("fidl_fuchsia_amber_ext_tests") {
   deps = [
-    ":fidl_fuchsia_amber_ext",
+    ":fidl_fuchsia_amber_ext_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/fidl_fuchsia_hardware_ethernet_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_hardware_ethernet_ext/BUILD.gn
index 3fd16ce..9e7012b 100644
--- a/garnet/lib/rust/fidl_fuchsia_hardware_ethernet_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_hardware_ethernet_ext/BUILD.gn
@@ -21,7 +21,7 @@
 
 unittest_package("fidl_fuchsia_hardware_ethernet_ext_tests") {
   deps = [
-    ":fidl_fuchsia_hardware_ethernet_ext",
+    ":fidl_fuchsia_hardware_ethernet_ext_test",
   ]
   tests = [
     {
diff --git a/garnet/lib/rust/fidl_fuchsia_net_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_net_ext/BUILD.gn
index 4d175e6..0746880 100644
--- a/garnet/lib/rust/fidl_fuchsia_net_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_net_ext/BUILD.gn
@@ -17,7 +17,7 @@
 
 unittest_package("fidl_fuchsia_net_ext_tests") {
   deps = [
-    ":fidl_fuchsia_net_ext",
+    ":fidl_fuchsia_net_ext_test",
   ]
   tests = [
     {
diff --git a/garnet/lib/rust/fidl_fuchsia_net_policy_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_net_policy_ext/BUILD.gn
index b3d5827..93682a6 100644
--- a/garnet/lib/rust/fidl_fuchsia_net_policy_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_net_policy_ext/BUILD.gn
@@ -20,7 +20,7 @@
 
 unittest_package("fidl_fuchsia_net_policy_ext_tests") {
   deps = [
-    ":fidl_fuchsia_net_policy_ext",
+    ":fidl_fuchsia_net_policy_ext_test",
   ]
   tests = [
     {
diff --git a/garnet/lib/rust/fidl_fuchsia_net_stack_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_net_stack_ext/BUILD.gn
index 9f564e5..9fa756f 100644
--- a/garnet/lib/rust/fidl_fuchsia_net_stack_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_net_stack_ext/BUILD.gn
@@ -20,7 +20,7 @@
 
 unittest_package("fidl_fuchsia_net_stack_ext_tests") {
   deps = [
-    ":fidl_fuchsia_net_stack_ext",
+    ":fidl_fuchsia_net_stack_ext_test",
   ]
   tests = [
     {
diff --git a/garnet/lib/rust/fidl_fuchsia_netstack_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_netstack_ext/BUILD.gn
index a003c44..3670177 100644
--- a/garnet/lib/rust/fidl_fuchsia_netstack_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_netstack_ext/BUILD.gn
@@ -17,7 +17,7 @@
 
 unittest_package("fidl_fuchsia_netstack_ext_tests") {
   deps = [
-    ":fidl_fuchsia_netstack_ext",
+    ":fidl_fuchsia_netstack_ext_test",
   ]
   tests = [
     {
diff --git a/garnet/lib/rust/fidl_fuchsia_pkg_ext/BUILD.gn b/garnet/lib/rust/fidl_fuchsia_pkg_ext/BUILD.gn
index 67aebbd..db82d21 100644
--- a/garnet/lib/rust/fidl_fuchsia_pkg_ext/BUILD.gn
+++ b/garnet/lib/rust/fidl_fuchsia_pkg_ext/BUILD.gn
@@ -26,7 +26,7 @@
 
 test_package("fidl_fuchsia_pkg_ext_tests") {
   deps = [
-    ":fidl_fuchsia_pkg_ext",
+    ":fidl_fuchsia_pkg_ext_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/fuchsia_pkg/BUILD.gn b/garnet/lib/rust/fuchsia_pkg/BUILD.gn
index 8bd81fc..4ee3ea0 100644
--- a/garnet/lib/rust/fuchsia_pkg/BUILD.gn
+++ b/garnet/lib/rust/fuchsia_pkg/BUILD.gn
@@ -31,7 +31,7 @@
 
 test_package("fuchsia_pkg_tests") {
   deps = [
-    ":fuchsia_pkg",
+    ":fuchsia_pkg_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/fuchsia_pkg_testing/BUILD.gn b/garnet/lib/rust/fuchsia_pkg_testing/BUILD.gn
index 1d37beb..4e9ccba 100644
--- a/garnet/lib/rust/fuchsia_pkg_testing/BUILD.gn
+++ b/garnet/lib/rust/fuchsia_pkg_testing/BUILD.gn
@@ -33,7 +33,7 @@
 
 test_package("fuchsia_pkg_testing_tests") {
   deps = [
-    ":fuchsia_pkg_testing",
+    ":fuchsia_pkg_testing_test",
   ]
 
   resources = [
diff --git a/garnet/lib/rust/httpdate-hyper/BUILD.gn b/garnet/lib/rust/httpdate-hyper/BUILD.gn
index 999dd43..5e98df9 100644
--- a/garnet/lib/rust/httpdate-hyper/BUILD.gn
+++ b/garnet/lib/rust/httpdate-hyper/BUILD.gn
@@ -30,7 +30,7 @@
 
 test_package("httpdate-hyper-tests") {
   deps = [
-    ":httpdate-hyper",
+    ":httpdate-hyper_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/intl/unicode_utils/char_collection/BUILD.gn b/garnet/lib/rust/intl/unicode_utils/char_collection/BUILD.gn
index ed8c531..1eb5a3db 100644
--- a/garnet/lib/rust/intl/unicode_utils/char_collection/BUILD.gn
+++ b/garnet/lib/rust/intl/unicode_utils/char_collection/BUILD.gn
@@ -21,7 +21,7 @@
 
 test_package("char_collection_tests") {
   deps = [
-    ":char_collection",
+    ":char_collection_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/io_util/BUILD.gn b/garnet/lib/rust/io_util/BUILD.gn
index fb94bb5..adf9a35 100644
--- a/garnet/lib/rust/io_util/BUILD.gn
+++ b/garnet/lib/rust/io_util/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("io_util_tests") {
   deps = [
-    ":io_util",
+    ":io_util_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/netfilter/BUILD.gn b/garnet/lib/rust/netfilter/BUILD.gn
index 4dd120d..1d0a2a5 100644
--- a/garnet/lib/rust/netfilter/BUILD.gn
+++ b/garnet/lib/rust/netfilter/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("netfilter_tests") {
   deps = [
-    ":netfilter",
+    ":netfilter_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/omaha_client/BUILD.gn b/garnet/lib/rust/omaha_client/BUILD.gn
index 4bbed0e..5ddec16 100644
--- a/garnet/lib/rust/omaha_client/BUILD.gn
+++ b/garnet/lib/rust/omaha_client/BUILD.gn
@@ -29,7 +29,7 @@
 
 test_package("omaha_client_lib_tests") {
   deps = [
-    ":omaha_client",
+    ":omaha_client_test",
   ]
 
   tests = [
diff --git a/garnet/lib/rust/webpki-roots-fuchsia/BUILD.gn b/garnet/lib/rust/webpki-roots-fuchsia/BUILD.gn
index ec18413..fce4f0f 100644
--- a/garnet/lib/rust/webpki-roots-fuchsia/BUILD.gn
+++ b/garnet/lib/rust/webpki-roots-fuchsia/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("webpki-roots-fuchsia_tests") {
   deps = [
-    ":webpki-roots-fuchsia",
+    ":webpki-roots-fuchsia_test",
   ]
 
   tests = [
diff --git a/garnet/public/lib/fidl/rust/fidl/BUILD.gn b/garnet/public/lib/fidl/rust/fidl/BUILD.gn
index 6b7a31d..f86fe4e 100644
--- a/garnet/public/lib/fidl/rust/fidl/BUILD.gn
+++ b/garnet/public/lib/fidl/rust/fidl/BUILD.gn
@@ -33,7 +33,7 @@
 
 test_package("rust_fidl_tests") {
   deps = [
-    ":fidl",
+    ":fidl_test",
     ":fidl.rust.test.compilation-rustc",
     "//garnet/public/lib/fidl/rust/fidl_tests:fidl_external_tests",
   ]
diff --git a/garnet/public/rust/BUILD.gn b/garnet/public/rust/BUILD.gn
index e5b1ad5..0dbb44e 100644
--- a/garnet/public/rust/BUILD.gn
+++ b/garnet/public/rust/BUILD.gn
@@ -7,21 +7,21 @@
 
 unittest_package("rust-crates-tests") {
   deps = [
-    "fuchsia-archive",
+    "fuchsia-archive:fuchsia-archive_test",
     "fuchsia-component:fuchsia-component-blackbox-unit-tests",
-    "fuchsia-cprng",
+    "fuchsia-cprng:fuchsia-cprng_test",
     "fuchsia-framebuffer",
     "fuchsia-hyper:fuchsia-hyper-tests",
-    "fuchsia-inspect",
-    "fuchsia-inspect-contrib",
-    "fuchsia-merkle",
-    "fuchsia-trace",
-    "fuchsia-vfs/pseudo-fs",
-    "mapped-vmo",
-    "mundane",
-    "packet",
-    "shared-buffer",
-    "zerocopy",
+    "fuchsia-inspect:fuchsia-inspect_test",
+    "fuchsia-inspect-contrib:fuchsia-inspect-contrib_test",
+    "fuchsia-merkle:fuchsia-merkle_test",
+    "fuchsia-trace:fuchsia-trace_test",
+    "fuchsia-vfs/pseudo-fs:pseudo-fs_test",
+    "mapped-vmo:mapped-vmo_test",
+    "mundane:mundane_test",
+    "packet:packet_test",
+    "shared-buffer:shared-buffer_test",
+    "zerocopy:zerocopy_test",
   ]
 
   tests = [
@@ -30,7 +30,7 @@
       environments = basic_envs
     },
     {
-      name = "fuchsia_component_blackbox_unit_tests_lib_test"
+      name = "fuchsia_component_blackbox_unit_tests"
       environments = basic_envs
     },
     {
diff --git a/garnet/public/rust/carnelian/BUILD.gn b/garnet/public/rust/carnelian/BUILD.gn
index 70f60e3..e4f04e8 100644
--- a/garnet/public/rust/carnelian/BUILD.gn
+++ b/garnet/public/rust/carnelian/BUILD.gn
@@ -332,7 +332,7 @@
 
 unittest_package("carnelian_tests") {
   deps = [
-    ":carnelian",
+    ":carnelian_test",
   ]
 
   tests = [
diff --git a/garnet/public/rust/fdio/BUILD.gn b/garnet/public/rust/fdio/BUILD.gn
index b94c5f9..2c0c897 100644
--- a/garnet/public/rust/fdio/BUILD.gn
+++ b/garnet/public/rust/fdio/BUILD.gn
@@ -32,7 +32,7 @@
   package_name = "fdio_rust_tests"
 
   deps = [
-    ":fdio",
+    ":fdio_test",
     ":spawn_test_target_bin",
   ]
 
diff --git a/garnet/public/rust/fuchsia-async/BUILD.gn b/garnet/public/rust/fuchsia-async/BUILD.gn
index 9f0eb53..3a219d9 100644
--- a/garnet/public/rust/fuchsia-async/BUILD.gn
+++ b/garnet/public/rust/fuchsia-async/BUILD.gn
@@ -28,7 +28,7 @@
 
 test_package("fuchsia-async-tests") {
   deps = [
-    ":fuchsia-async",
+    ":fuchsia-async_test",
   ]
 
   tests = [
diff --git a/garnet/public/rust/fuchsia-component/BUILD.gn b/garnet/public/rust/fuchsia-component/BUILD.gn
index fc81fde..3740226 100644
--- a/garnet/public/rust/fuchsia-component/BUILD.gn
+++ b/garnet/public/rust/fuchsia-component/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 
 rustc_library("fuchsia-component") {
   version = "0.1.0"
@@ -24,10 +25,9 @@
   ]
 }
 
-rustc_library("fuchsia-component-blackbox-unit-tests") {
+rustc_test("fuchsia-component-blackbox-unit-tests") {
   edition = "2018"
   source_root = "blackbox_unit_tests/lib.rs"
-  with_unit_tests = true
   deps = [
     ":fuchsia-component",
     "//garnet/public/lib/fidl/rust/fidl",
diff --git a/garnet/public/rust/fuchsia-hyper/BUILD.gn b/garnet/public/rust/fuchsia-hyper/BUILD.gn
index 232d0f55..9a13c40 100644
--- a/garnet/public/rust/fuchsia-hyper/BUILD.gn
+++ b/garnet/public/rust/fuchsia-hyper/BUILD.gn
@@ -23,7 +23,7 @@
 
 test_package("fuchsia-hyper-tests") {
   deps = [
-    ":fuchsia-hyper",
+    ":fuchsia-hyper_test",
   ]
 
   tests = [
diff --git a/garnet/public/rust/fuchsia-syslog/BUILD.gn b/garnet/public/rust/fuchsia-syslog/BUILD.gn
index 1d3d1fd..19e01c4 100644
--- a/garnet/public/rust/fuchsia-syslog/BUILD.gn
+++ b/garnet/public/rust/fuchsia-syslog/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("fuchsia-syslog-tests") {
   deps = [
-    ":fuchsia-syslog",
+    ":fuchsia-syslog_test",
   ]
 
   tests = [
diff --git a/garnet/public/rust/tuf/BUILD.gn b/garnet/public/rust/tuf/BUILD.gn
index 2f8b904..ea05684 100644
--- a/garnet/public/rust/tuf/BUILD.gn
+++ b/garnet/public/rust/tuf/BUILD.gn
@@ -35,7 +35,7 @@
 
 test_package("tuf-tests") {
   deps = [
-    ":tuf",
+    ":tuf_test",
   ]
 
   tests = [
diff --git a/garnet/tests/amberctl/BUILD.gn b/garnet/tests/amberctl/BUILD.gn
index 7e2592c..f7f7ea1 100644
--- a/garnet/tests/amberctl/BUILD.gn
+++ b/garnet/tests/amberctl/BUILD.gn
@@ -3,14 +3,13 @@
 # found in the LICENSE file.
 
 import("//build/package.gni")
-import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 import("//build/test/test_package.gni")
 import("//build/testing/environments.gni")
 
-rustc_library("driver") {
-  name = "amberctl-tests"
+rustc_test("driver") {
+  name = "amberctl-test"
   edition = "2018"
-  with_unit_tests = true
 
   deps = [
     "//garnet/lib/rust/fidl_fuchsia_amber_ext",
@@ -87,7 +86,7 @@
 
   tests = [
     {
-      name = "amberctl_tests_lib_test"
+      name = "amberctl_test"
       environments = basic_envs
     },
   ]
diff --git a/garnet/tests/amberctl/meta/amberctl_tests_lib_test.cmx b/garnet/tests/amberctl/meta/amberctl_test.cmx
similarity index 83%
copy from garnet/tests/amberctl/meta/amberctl_tests_lib_test.cmx
copy to garnet/tests/amberctl/meta/amberctl_test.cmx
index 40a3242..7c74096 100644
--- a/garnet/tests/amberctl/meta/amberctl_tests_lib_test.cmx
+++ b/garnet/tests/amberctl/meta/amberctl_test.cmx
@@ -1,6 +1,6 @@
 {
     "program": {
-        "binary": "test/amberctl_tests_lib_test"
+        "binary": "test/amberctl_test"
     },
     "sandbox": {
         "features": [
diff --git a/garnet/tests/system_updater/BUILD.gn b/garnet/tests/system_updater/BUILD.gn
index de93a4f..4051874 100644
--- a/garnet/tests/system_updater/BUILD.gn
+++ b/garnet/tests/system_updater/BUILD.gn
@@ -3,14 +3,13 @@
 # found in the LICENSE file.
 
 import("//build/package.gni")
-import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 import("//build/test/test_package.gni")
 import("//build/testing/environments.gni")
 
-rustc_library("driver") {
-  name = "system_updater_tests"
+rustc_test("driver") {
+  name = "system_updater_v2_test"
   edition = "2018"
-  with_unit_tests = true
 
   deps = [
     "//garnet/go/src/amber:cobalt_sw_delivery_registry_rustlib",
@@ -72,7 +71,7 @@
 
   tests = [
     {
-      name = "system_updater_tests_lib_test"
+      name = "system_updater_v2_test"
       environments = basic_envs
     },
   ]
diff --git a/garnet/tests/system_updater/meta/system_updater_tests_lib_test.cmx b/garnet/tests/system_updater/meta/system_updater_tests_lib_test.cmx
deleted file mode 100644
index e22bf47..0000000
--- a/garnet/tests/system_updater/meta/system_updater_tests_lib_test.cmx
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-    "program": {
-        "binary": "test/system_updater_tests_lib_test"
-    },
-    "sandbox": {
-        "features": [
-            "system-temp"
-        ],
-        "services": [
-            "fuchsia.sys.Environment",
-            "fuchsia.sys.Launcher",
-            "fuchsia.sys.Loader"
-        ]
-    }
-}
diff --git a/garnet/tests/amberctl/meta/amberctl_tests_lib_test.cmx b/garnet/tests/system_updater/meta/system_updater_v2_test.cmx
similarity index 83%
rename from garnet/tests/amberctl/meta/amberctl_tests_lib_test.cmx
rename to garnet/tests/system_updater/meta/system_updater_v2_test.cmx
index 40a3242..fb8f969 100644
--- a/garnet/tests/amberctl/meta/amberctl_tests_lib_test.cmx
+++ b/garnet/tests/system_updater/meta/system_updater_v2_test.cmx
@@ -1,6 +1,6 @@
 {
     "program": {
-        "binary": "test/amberctl_tests_lib_test"
+        "binary": "test/system_updater_v2_test"
     },
     "sandbox": {
         "features": [
diff --git a/peridot/bin/discovermgr/BUILD.gn b/peridot/bin/discovermgr/BUILD.gn
index 66bf0a0..637651c 100644
--- a/peridot/bin/discovermgr/BUILD.gn
+++ b/peridot/bin/discovermgr/BUILD.gn
@@ -55,7 +55,7 @@
 
 test_package("discovermgr_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   resources = [
diff --git a/peridot/bin/module_resolver_rs/BUILD.gn b/peridot/bin/module_resolver_rs/BUILD.gn
index 27b6ebc..986c361 100644
--- a/peridot/bin/module_resolver_rs/BUILD.gn
+++ b/peridot/bin/module_resolver_rs/BUILD.gn
@@ -39,7 +39,7 @@
 
 unittest_package("module_resolver_rs_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/peridot/bin/voila/BUILD.gn b/peridot/bin/voila/BUILD.gn
index 92b96dc..f858d9e2 100644
--- a/peridot/bin/voila/BUILD.gn
+++ b/peridot/bin/voila/BUILD.gn
@@ -64,7 +64,7 @@
 
 test_package("voila_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
     "//peridot/bin/voila/testing/session_shell",
   ]
   tests = [
diff --git a/peridot/lib/sequential_futures/BUILD.gn b/peridot/lib/sequential_futures/BUILD.gn
index 685bdf5..2e77932 100644
--- a/peridot/lib/sequential_futures/BUILD.gn
+++ b/peridot/lib/sequential_futures/BUILD.gn
@@ -31,7 +31,8 @@
 }
 
 group("tests") {
+  testonly = true
   public_deps = [
-    ":sequential_futures",
+    ":sequential_futures_test",
   ]
 }
diff --git a/src/connectivity/bluetooth/core/bt-gap/BUILD.gn b/src/connectivity/bluetooth/core/bt-gap/BUILD.gn
index c3eada5..8716ebb 100644
--- a/src/connectivity/bluetooth/core/bt-gap/BUILD.gn
+++ b/src/connectivity/bluetooth/core/bt-gap/BUILD.gn
@@ -59,7 +59,7 @@
   package_name = "bt-gap-tests"
 
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/lib/bt-avctp/BUILD.gn b/src/connectivity/bluetooth/lib/bt-avctp/BUILD.gn
index 93889c5..83b1a30 100644
--- a/src/connectivity/bluetooth/lib/bt-avctp/BUILD.gn
+++ b/src/connectivity/bluetooth/lib/bt-avctp/BUILD.gn
@@ -28,7 +28,7 @@
   package_name = "bt-avctp-tests"
 
   deps = [
-    ":bt-avctp",
+    ":bt-avctp_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/lib/bt-avdtp/BUILD.gn b/src/connectivity/bluetooth/lib/bt-avdtp/BUILD.gn
index 5789686..d50f92a 100644
--- a/src/connectivity/bluetooth/lib/bt-avdtp/BUILD.gn
+++ b/src/connectivity/bluetooth/lib/bt-avdtp/BUILD.gn
@@ -29,7 +29,7 @@
   package_name = "bt-avdtp-tests"
 
   deps = [
-    ":bt-avdtp",
+    ":bt-avdtp_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/lib/fuchsia-bluetooth/BUILD.gn b/src/connectivity/bluetooth/lib/fuchsia-bluetooth/BUILD.gn
index 293483b..c3811da 100644
--- a/src/connectivity/bluetooth/lib/fuchsia-bluetooth/BUILD.gn
+++ b/src/connectivity/bluetooth/lib/fuchsia-bluetooth/BUILD.gn
@@ -37,7 +37,7 @@
   package_name = "bluetooth-crate-tests"
 
   deps = [
-    ":fuchsia-bluetooth",
+    ":fuchsia-bluetooth_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/profiles/bt-a2dp-sink/BUILD.gn b/src/connectivity/bluetooth/profiles/bt-a2dp-sink/BUILD.gn
index 4d2c38d..45eb7c8 100644
--- a/src/connectivity/bluetooth/profiles/bt-a2dp-sink/BUILD.gn
+++ b/src/connectivity/bluetooth/profiles/bt-a2dp-sink/BUILD.gn
@@ -67,7 +67,7 @@
   package_name = "bt-a2dp-sink-tests"
 
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/tools/bt-avrcp-controller/BUILD.gn b/src/connectivity/bluetooth/tools/bt-avrcp-controller/BUILD.gn
index dbd1024..531d83a 100644
--- a/src/connectivity/bluetooth/tools/bt-avrcp-controller/BUILD.gn
+++ b/src/connectivity/bluetooth/tools/bt-avrcp-controller/BUILD.gn
@@ -31,7 +31,7 @@
   package_name = "bt-avrcp-controller-tests"
 
   deps = [
-    ":bt-avrcp-controller",
+    ":bt-avrcp-controller_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/tools/bt-cli/BUILD.gn b/src/connectivity/bluetooth/tools/bt-cli/BUILD.gn
index 672b4295..2e655b3 100644
--- a/src/connectivity/bluetooth/tools/bt-cli/BUILD.gn
+++ b/src/connectivity/bluetooth/tools/bt-cli/BUILD.gn
@@ -30,7 +30,7 @@
   package_name = "bt-cli-tests"
 
   deps = [
-    ":bt-cli",
+    ":bt-cli_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/tools/bt-snoop/BUILD.gn b/src/connectivity/bluetooth/tools/bt-snoop/BUILD.gn
index 87467bd..0d16956 100644
--- a/src/connectivity/bluetooth/tools/bt-snoop/BUILD.gn
+++ b/src/connectivity/bluetooth/tools/bt-snoop/BUILD.gn
@@ -48,7 +48,7 @@
   package_name = "bt-snoop-tests"
 
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/connectivity/bluetooth/tools/tests/bt-tool-cli-tests/BUILD.gn b/src/connectivity/bluetooth/tools/tests/bt-tool-cli-tests/BUILD.gn
index 01b688d..397910f 100644
--- a/src/connectivity/bluetooth/tools/tests/bt-tool-cli-tests/BUILD.gn
+++ b/src/connectivity/bluetooth/tools/tests/bt-tool-cli-tests/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("bt-tool-cli-tests") {
   deps = [
-    ":lib",
+    ":lib_test",
     "//src/connectivity/bluetooth/tools/bt-avrcp-controller",
     "//src/connectivity/bluetooth/tools/bt-snoop-cli",
   ]
diff --git a/src/connectivity/network/dhcp/BUILD.gn b/src/connectivity/network/dhcp/BUILD.gn
index 6b1800e..3ce9f1b 100644
--- a/src/connectivity/network/dhcp/BUILD.gn
+++ b/src/connectivity/network/dhcp/BUILD.gn
@@ -24,7 +24,7 @@
 
 unittest_package("dhcp_tests") {
   deps = [
-    ":dhcp",
+    ":dhcp_test",
   ]
   tests = [
     {
diff --git a/src/connectivity/network/http_client/integration/BUILD.gn b/src/connectivity/network/http_client/integration/BUILD.gn
index 030fd23..5223d4d 100644
--- a/src/connectivity/network/http_client/integration/BUILD.gn
+++ b/src/connectivity/network/http_client/integration/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 import("//build/test/test_package.gni")
 import("//build/testing/environments.gni")
 
@@ -14,10 +15,8 @@
   ]
 }
 
-rustc_library("bin") {
-  testonly = true
-  with_unit_tests = true
-  name = "http_client_integration"
+rustc_test("test") {
+  name = "http_client_integration_test"
   edition = "2018"
 
   deps = [
@@ -36,12 +35,12 @@
 
 test_package("http_client_integration_test") {
   deps = [
-    ":bin",
+    ":test",
   ]
 
   tests = [
     {
-      name = "http_client_integration_lib_test"
+      name = "http_client_integration_test"
       environments = basic_envs
     },
   ]
diff --git a/src/connectivity/network/http_client/integration/meta/http_client_integration_lib_test.cmx b/src/connectivity/network/http_client/integration/meta/http_client_integration_test.cmx
similarity index 84%
rename from src/connectivity/network/http_client/integration/meta/http_client_integration_lib_test.cmx
rename to src/connectivity/network/http_client/integration/meta/http_client_integration_test.cmx
index 875ba2c..0a0e954 100644
--- a/src/connectivity/network/http_client/integration/meta/http_client_integration_lib_test.cmx
+++ b/src/connectivity/network/http_client/integration/meta/http_client_integration_test.cmx
@@ -7,7 +7,7 @@
         }
     },
     "program": {
-        "binary": "test/http_client_integration_lib_test"
+        "binary": "test/http_client_integration_test"
     },
     "sandbox": {
         "services": [
diff --git a/src/connectivity/network/netstack3/BUILD.gn b/src/connectivity/network/netstack3/BUILD.gn
index de80cd7..b4a9f79 100644
--- a/src/connectivity/network/netstack3/BUILD.gn
+++ b/src/connectivity/network/netstack3/BUILD.gn
@@ -54,9 +54,9 @@
 
 test_package("netstack3_tests") {
   deps = [
-    ":bin",
-    "core:netstack3-core",
-    "core/specialize-ip-macro/test:lib",
+    ":bin_test",
+    "core:netstack3-core_test",
+    "core/specialize-ip-macro/test:lib_test",
   ]
   tests = [
     {
diff --git a/src/connectivity/network/testing/netemul/runner/test/BUILD.gn b/src/connectivity/network/testing/netemul/runner/test/BUILD.gn
index ec4aad23..8a20397 100644
--- a/src/connectivity/network/testing/netemul/runner/test/BUILD.gn
+++ b/src/connectivity/network/testing/netemul/runner/test/BUILD.gn
@@ -50,10 +50,10 @@
     "inheritance",
     "netstack_intermediary",
     "netstack_socks",
-    "sandbox_service",
+    "sandbox_service:sandbox_service_test",
     "svc_list",
     "//src/connectivity/network/testing/netemul/runner:sandbox_unittest",
-    "//src/connectivity/network/testing/netemul/runner/helpers/mock_device_settings",
+    "//src/connectivity/network/testing/netemul/runner/helpers/mock_device_settings:mock_device_settings_test",
     "//src/connectivity/network/testing/netemul/runner/model:model_unittest",
   ]
 
diff --git a/src/connectivity/network/tests/BUILD.gn b/src/connectivity/network/tests/BUILD.gn
index f04614a..ad52360 100644
--- a/src/connectivity/network/tests/BUILD.gn
+++ b/src/connectivity/network/tests/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 import("//build/test.gni")
 import("//build/test/test_package.gni")
 import("//build/testing/environments.gni")
@@ -24,9 +24,7 @@
   ]
 }
 
-rustc_library("netstack_fidl_integration") {
-  testonly = true
-  with_unit_tests = true
+rustc_test("netstack_fidl_integration_test") {
   edition = "2018"
 
   deps = [
@@ -80,12 +78,12 @@
 
 test_package("netstack_integration_tests") {
   deps = [
-    ":netstack_fidl_integration",
+    ":netstack_fidl_integration_test",
   ]
 
   tests = [
     {
-      name = "netstack_fidl_integration_lib_test"
+      name = "netstack_fidl_integration_test"
       environments = [ qemu_env ]
     },
   ]
diff --git a/src/connectivity/network/tests/meta/netstack_fidl_integration_lib_test.cmx b/src/connectivity/network/tests/meta/netstack_fidl_integration_test.cmx
similarity index 85%
rename from src/connectivity/network/tests/meta/netstack_fidl_integration_lib_test.cmx
rename to src/connectivity/network/tests/meta/netstack_fidl_integration_test.cmx
index f9c4c8c..7ed9b4e 100644
--- a/src/connectivity/network/tests/meta/netstack_fidl_integration_lib_test.cmx
+++ b/src/connectivity/network/tests/meta/netstack_fidl_integration_test.cmx
@@ -7,7 +7,7 @@
         }
     },
     "program": {
-        "binary": "test/netstack_fidl_integration_lib_test"
+        "binary": "test/netstack_fidl_integration_test"
     },
     "sandbox": {
         "services": [
diff --git a/src/connectivity/telephony/lib/qmi-protocol/BUILD.gn b/src/connectivity/telephony/lib/qmi-protocol/BUILD.gn
index a8327ee..234fcb4 100644
--- a/src/connectivity/telephony/lib/qmi-protocol/BUILD.gn
+++ b/src/connectivity/telephony/lib/qmi-protocol/BUILD.gn
@@ -6,6 +6,7 @@
 import("//build/package.gni")
 import("//build/rust/rustc_binary.gni")
 import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 
 # Generate the rust sources using the gen.
 compiled_action("gen_qmi_protocol_source") {
@@ -67,10 +68,8 @@
     ]
   }
 
-  rustc_library("qmigen_unittests") {
+  rustc_test("qmigen_unittests") {
     edition = "2018"
-    with_unit_tests = true
-    testonly = true
 
     deps = [
       ":qmigen",
diff --git a/src/connectivity/telephony/ril-qmi/BUILD.gn b/src/connectivity/telephony/ril-qmi/BUILD.gn
index 54eb9b6..cb35aff 100644
--- a/src/connectivity/telephony/ril-qmi/BUILD.gn
+++ b/src/connectivity/telephony/ril-qmi/BUILD.gn
@@ -49,7 +49,7 @@
   package_name = "ril-qmi-tests"
 
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/bitfield/wlan-bitfield-tests/BUILD.gn b/src/connectivity/wlan/lib/bitfield/wlan-bitfield-tests/BUILD.gn
index 412f571..4f46f18 100644
--- a/src/connectivity/wlan/lib/bitfield/wlan-bitfield-tests/BUILD.gn
+++ b/src/connectivity/wlan/lib/bitfield/wlan-bitfield-tests/BUILD.gn
@@ -19,7 +19,7 @@
 
 test_package("wlan-bitfield-tests") {
   deps = [
-    ":wlan-bitfield-wrapper",
+    ":wlan-bitfield-wrapper_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/common/rust/BUILD.gn b/src/connectivity/wlan/lib/common/rust/BUILD.gn
index 0cd7cd3..2f6390c 100644
--- a/src/connectivity/wlan/lib/common/rust/BUILD.gn
+++ b/src/connectivity/wlan/lib/common/rust/BUILD.gn
@@ -30,7 +30,7 @@
 
 test_package("wlan-common-tests") {
   deps = [
-    ":wlan-common",
+    ":wlan-common_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/eapol/BUILD.gn b/src/connectivity/wlan/lib/eapol/BUILD.gn
index d9323c0..9c12108 100644
--- a/src/connectivity/wlan/lib/eapol/BUILD.gn
+++ b/src/connectivity/wlan/lib/eapol/BUILD.gn
@@ -20,7 +20,7 @@
 
 unittest_package("eapol-tests") {
   deps = [
-    ":eapol",
+    ":eapol_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/inspect/BUILD.gn b/src/connectivity/wlan/lib/inspect/BUILD.gn
index 9979f1a..c8f1f75 100644
--- a/src/connectivity/wlan/lib/inspect/BUILD.gn
+++ b/src/connectivity/wlan/lib/inspect/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("wlan-inspect-tests") {
   deps = [
-    ":wlan-inspect",
+    ":wlan-inspect_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/mlme/rust/BUILD.gn b/src/connectivity/wlan/lib/mlme/rust/BUILD.gn
index 9abd5c03..e67d00a 100644
--- a/src/connectivity/wlan/lib/mlme/rust/BUILD.gn
+++ b/src/connectivity/wlan/lib/mlme/rust/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("wlan-mlme-tests") {
   deps = [
-    ":wlan-mlme",
+    ":wlan-mlme_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/mlme/rust/c-binding/BUILD.gn b/src/connectivity/wlan/lib/mlme/rust/c-binding/BUILD.gn
index 3342c94..f462c6a 100644
--- a/src/connectivity/wlan/lib/mlme/rust/c-binding/BUILD.gn
+++ b/src/connectivity/wlan/lib/mlme/rust/c-binding/BUILD.gn
@@ -30,7 +30,7 @@
 
 unittest_package("wlan-mlme-c-tests") {
   deps = [
-    ":wlan-mlme-c",
+    ":wlan-mlme-c_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/rsn/BUILD.gn b/src/connectivity/wlan/lib/rsn/BUILD.gn
index 5ff551f..19249f1 100644
--- a/src/connectivity/wlan/lib/rsn/BUILD.gn
+++ b/src/connectivity/wlan/lib/rsn/BUILD.gn
@@ -33,7 +33,7 @@
 
 test_package("wlan-rsn-tests") {
   deps = [
-    ":wlan-rsn",
+    ":wlan-rsn_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/sme/BUILD.gn b/src/connectivity/wlan/lib/sme/BUILD.gn
index 38aae4e..8f0faba 100644
--- a/src/connectivity/wlan/lib/sme/BUILD.gn
+++ b/src/connectivity/wlan/lib/sme/BUILD.gn
@@ -38,7 +38,7 @@
 
 test_package("wlan-sme-tests") {
   deps = [
-    ":wlan-sme",
+    ":wlan-sme_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/lib/wep_deprecated/BUILD.gn b/src/connectivity/wlan/lib/wep_deprecated/BUILD.gn
index 464ccec..e31fdac 100644
--- a/src/connectivity/wlan/lib/wep_deprecated/BUILD.gn
+++ b/src/connectivity/wlan/lib/wep_deprecated/BUILD.gn
@@ -36,7 +36,7 @@
 
 unittest_package("wep-deprecated-tests") {
   deps = [
-    ":wep_deprecated",
+    ":wep_deprecated_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/testing/hw-sim/BUILD.gn b/src/connectivity/wlan/testing/hw-sim/BUILD.gn
index 0ea459b..140a555 100644
--- a/src/connectivity/wlan/testing/hw-sim/BUILD.gn
+++ b/src/connectivity/wlan/testing/hw-sim/BUILD.gn
@@ -54,7 +54,7 @@
 
 test_package("wlan-hw-sim-tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/tools/wlantool/BUILD.gn b/src/connectivity/wlan/tools/wlantool/BUILD.gn
index 0e0e644..df72d30 100644
--- a/src/connectivity/wlan/tools/wlantool/BUILD.gn
+++ b/src/connectivity/wlan/tools/wlantool/BUILD.gn
@@ -48,7 +48,7 @@
 
 test_package("wlan-tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/connectivity/wlan/wlancfg/BUILD.gn b/src/connectivity/wlan/wlancfg/BUILD.gn
index c58813b..bdb6905 100644
--- a/src/connectivity/wlan/wlancfg/BUILD.gn
+++ b/src/connectivity/wlan/wlancfg/BUILD.gn
@@ -89,7 +89,7 @@
 
 test_package("wlancfg-tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
   tests = [
     {
diff --git a/src/connectivity/wlan/wlanstack/BUILD.gn b/src/connectivity/wlan/wlanstack/BUILD.gn
index 54fb335..43ca543 100644
--- a/src/connectivity/wlan/wlanstack/BUILD.gn
+++ b/src/connectivity/wlan/wlanstack/BUILD.gn
@@ -80,7 +80,7 @@
 
 test_package("wlanstack-tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/graphics/lib/compute/hotsort/platforms/vk/tests/BUILD.gn b/src/graphics/lib/compute/hotsort/platforms/vk/tests/BUILD.gn
index f846dc3..08c6224 100644
--- a/src/graphics/lib/compute/hotsort/platforms/vk/tests/BUILD.gn
+++ b/src/graphics/lib/compute/hotsort/platforms/vk/tests/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 group("tests") {
+  testonly = true
   public_deps = [
     "hotsort_vk_bench",
   ]
diff --git a/src/graphics/lib/compute/spinel-rs/BUILD.gn b/src/graphics/lib/compute/spinel-rs/BUILD.gn
index 896c3cd..c60a150 100644
--- a/src/graphics/lib/compute/spinel-rs/BUILD.gn
+++ b/src/graphics/lib/compute/spinel-rs/BUILD.gn
@@ -28,7 +28,7 @@
 package("spinel-rs-tests") {
   testonly = true
   deps = [
-    ":spinel-rs",
+    ":spinel-rs_test",
   ]
   tests = [
     {
diff --git a/src/graphics/lib/compute/spinel/platforms/vk/tests/BUILD.gn b/src/graphics/lib/compute/spinel/platforms/vk/tests/BUILD.gn
index 9d8728c..29a9842 100644
--- a/src/graphics/lib/compute/spinel/platforms/vk/tests/BUILD.gn
+++ b/src/graphics/lib/compute/spinel/platforms/vk/tests/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 group("tests") {
+  testonly = true
   public_deps = [
     "spinel_vk_context",
     "spinel_vk_path_builder",
diff --git a/src/identity/bin/BUILD.gn b/src/identity/bin/BUILD.gn
index a1a0375..e42b472 100644
--- a/src/identity/bin/BUILD.gn
+++ b/src/identity/bin/BUILD.gn
@@ -21,12 +21,12 @@
 
 test_package("identity_bin_unittests") {
   deps = [
-    "account_handler:bin",
-    "account_manager:bin",
-    "dev_auth_provider:bin",
-    "dev_auth_provider_iotid:bin",
+    "account_handler:bin_test",
+    "account_manager:bin_test",
+    "dev_auth_provider:bin_test",
+    "dev_auth_provider_iotid:bin_test",
     "google_auth_provider:google_auth_provider_unittests",
-    "google_auth_provider_rust:bin",
+    "google_auth_provider_rust:bin_test",
   ]
 
   tests = [
diff --git a/src/identity/lib/BUILD.gn b/src/identity/lib/BUILD.gn
index 1f5ef18..3087930 100644
--- a/src/identity/lib/BUILD.gn
+++ b/src/identity/lib/BUILD.gn
@@ -21,12 +21,12 @@
 
 test_package("identity_lib_unittests") {
   deps = [
-    "account_common",
-    "identity_common",
+    "account_common:account_common_test",
+    "identity_common:identity_common_test",
     "oauth:oauth_unittests",
-    "token_cache",
-    "token_store",
-    "token_manager",
+    "token_cache:token_cache_test",
+    "token_store:token_store_test",
+    "token_manager:token_manager_test",
   ]
 
   tests = [
diff --git a/src/identity/tests/account_manager_integration/BUILD.gn b/src/identity/tests/account_manager_integration/BUILD.gn
index def340a..96116c6 100644
--- a/src/identity/tests/account_manager_integration/BUILD.gn
+++ b/src/identity/tests/account_manager_integration/BUILD.gn
@@ -3,7 +3,7 @@
 # found in the LICENSE file.
 #
 
-import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 import("//build/test/test_package.gni")
 import("//build/testing/environments.gni")
 
@@ -16,11 +16,9 @@
   ]
 }
 
-rustc_library("lib") {
-  name = "account_manager_integration"
+rustc_test("test") {
+  name = "account_manager_integration_test"
   edition = "2018"
-  testonly = true
-  with_unit_tests = true
 
   source_root = "tests/lib.rs"
 
@@ -43,12 +41,12 @@
 
 test_package("account_manager_integration_test_pkg") {
   deps = [
-    ":lib",
+    ":test",
   ]
 
   tests = [
     {
-      name = "account_manager_integration_lib_test"
+      name = "account_manager_integration_test"
       environments = basic_envs
     },
   ]
diff --git a/src/identity/tests/account_manager_integration/meta/account_manager_integration_lib_test.cmx b/src/identity/tests/account_manager_integration/meta/account_manager_integration_test.cmx
similarity index 75%
rename from src/identity/tests/account_manager_integration/meta/account_manager_integration_lib_test.cmx
rename to src/identity/tests/account_manager_integration/meta/account_manager_integration_test.cmx
index 66ef6c8..0afcff1 100644
--- a/src/identity/tests/account_manager_integration/meta/account_manager_integration_lib_test.cmx
+++ b/src/identity/tests/account_manager_integration/meta/account_manager_integration_test.cmx
@@ -1,6 +1,6 @@
 {
     "program": {
-        "binary": "test/account_manager_integration_lib_test"
+        "binary": "test/account_manager_integration_test"
     },
     "sandbox": {
         "services": [
diff --git a/src/ledger/cloud_provider_memory_diff/BUILD.gn b/src/ledger/cloud_provider_memory_diff/BUILD.gn
index 6da44d8..b9564c4 100644
--- a/src/ledger/cloud_provider_memory_diff/BUILD.gn
+++ b/src/ledger/cloud_provider_memory_diff/BUILD.gn
@@ -42,7 +42,7 @@
 
 test_package("cloud_provider_memory_diff_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
     "validation",
   ]
 
diff --git a/src/lib/cobalt/BUILD.gn b/src/lib/cobalt/BUILD.gn
index 32ebd8e..7ae7ac2 100644
--- a/src/lib/cobalt/BUILD.gn
+++ b/src/lib/cobalt/BUILD.gn
@@ -29,7 +29,7 @@
   deps = [
     ":unittests",
     "//src/lib/cobalt/cpp:test_metrics_registry",
-    "//src/lib/cobalt/rust:fuchsia-cobalt",
+    "//src/lib/cobalt/rust:fuchsia-cobalt_test",
   ]
 
   tests = [
diff --git a/src/lib/fidl_table_validation/fidl_table_validation_tests/BUILD.gn b/src/lib/fidl_table_validation/fidl_table_validation_tests/BUILD.gn
index b2e3013..edff0a6 100644
--- a/src/lib/fidl_table_validation/fidl_table_validation_tests/BUILD.gn
+++ b/src/lib/fidl_table_validation/fidl_table_validation_tests/BUILD.gn
@@ -14,7 +14,7 @@
 
 test_package("fidl_table_validation_tests") {
   deps = [
-    ":fidl_table_validation_tests_bin",
+    ":fidl_table_validation_tests_bin_test",
   ]
 
   tests = [
diff --git a/src/lib/process_builder/BUILD.gn b/src/lib/process_builder/BUILD.gn
index f2e47ec..7f6dea1 100644
--- a/src/lib/process_builder/BUILD.gn
+++ b/src/lib/process_builder/BUILD.gn
@@ -111,7 +111,7 @@
 
 test_package("process_builder_tests") {
   deps = [
-    ":process_builder",
+    ":process_builder_test",
     ":root_job_test_runner",
     ":static_pie_test_util",
     ":test_util",
diff --git a/src/lib/rust_backtrace/BUILD.gn b/src/lib/rust_backtrace/BUILD.gn
index 5dd474b..57a0645 100644
--- a/src/lib/rust_backtrace/BUILD.gn
+++ b/src/lib/rust_backtrace/BUILD.gn
@@ -20,7 +20,7 @@
   testonly = true
 
   deps = [
-    ":rust_backtrace",
+    ":rust_backtrace_test",
   ]
 
   tests = [
diff --git a/src/lib/ui/input-synthesis/BUILD.gn b/src/lib/ui/input-synthesis/BUILD.gn
index 0511439..145e58f 100644
--- a/src/lib/ui/input-synthesis/BUILD.gn
+++ b/src/lib/ui/input-synthesis/BUILD.gn
@@ -21,7 +21,7 @@
 package("input-synthesis-tests") {
   testonly = true
   deps = [
-    ":input-synthesis",
+    ":input-synthesis_test",
   ]
   tests = [
     {
diff --git a/src/media/sessions/BUILD.gn b/src/media/sessions/BUILD.gn
index b65f37b..b8b1bc1 100644
--- a/src/media/sessions/BUILD.gn
+++ b/src/media/sessions/BUILD.gn
@@ -65,7 +65,7 @@
 
 test_package("mediasession_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/media/stream_processors/test/BUILD.gn b/src/media/stream_processors/test/BUILD.gn
index cb0affe..7eafc56 100644
--- a/src/media/stream_processors/test/BUILD.gn
+++ b/src/media/stream_processors/test/BUILD.gn
@@ -42,7 +42,7 @@
 
 test_package("stream_processor_lib_test") {
   deps = [
-    ":stream_processor_test_lib",
+    ":stream_processor_test_lib_test",
   ]
 
   tests = [
@@ -87,12 +87,10 @@
   ]
 }
 
-rustc_library("audio_encoder_test_lib") {
+rustc_test("audio_encoder_test_bin") {
   name = "audio_encoder_test"
   edition = "2018"
   source_root = "audio_encoder_test/lib.rs"
-  testonly = true
-  with_unit_tests = true
 
   deps = [
     ":stream_processor_encoder_factory_lib",
@@ -110,18 +108,19 @@
 
 test_package("audio_encoder_test") {
   deps = [
-    ":audio_encoder_test_lib",
+    ":audio_encoder_test_bin",
   ]
 
   tests = [
     {
-      name = "audio_encoder_test_lib_test"
+      name = "audio_encoder_test"
       environments = basic_envs
     },
   ]
 }
 
 rustc_test("h264_decoder_test_bin") {
+  name = "h264_decoder_test"
   edition = "2018"
   source_root = "h264_decoder_test/lib.rs"
 
@@ -146,7 +145,7 @@
 
   tests = [
     {
-      name = "h264_decoder_test_bin"
+      name = "h264_decoder_test"
       environments = basic_envs
     },
   ]
diff --git a/src/media/stream_processors/test/meta/h264_decoder_test_bin.cmx b/src/media/stream_processors/test/meta/audio_encoder_test.cmx
similarity index 93%
rename from src/media/stream_processors/test/meta/h264_decoder_test_bin.cmx
rename to src/media/stream_processors/test/meta/audio_encoder_test.cmx
index 1abfd5eb..1ee1985 100644
--- a/src/media/stream_processors/test/meta/h264_decoder_test_bin.cmx
+++ b/src/media/stream_processors/test/meta/audio_encoder_test.cmx
@@ -8,7 +8,7 @@
         }
     },
     "program": {
-        "binary": "test/h264_decoder_test_bin"
+        "binary": "test/audio_encoder_test"
     },
     "sandbox": {
         "dev": [
diff --git a/src/media/stream_processors/test/meta/audio_encoder_test_lib_test.cmx b/src/media/stream_processors/test/meta/audio_encoder_test_lib_test.cmx
deleted file mode 100644
index bad471bf..0000000
--- a/src/media/stream_processors/test/meta/audio_encoder_test_lib_test.cmx
+++ /dev/null
@@ -1,26 +0,0 @@
-{
-    "facets": {
-        "fuchsia.test": {
-            "injected-services": {
-                "fuchsia.mediacodec.CodecFactory": "fuchsia-pkg://fuchsia.com/codec_factory#meta/codec_factory.cmx",
-                "fuchsia.sysmem.Allocator": "fuchsia-pkg://fuchsia.com/sysmem_connector#meta/sysmem_connector.cmx"
-            }
-        }
-    },
-    "program": {
-        "binary": "test/audio_encoder_test_lib_test"
-    },
-    "sandbox": {
-        "dev": [
-            "class/media-codec",
-            "class/sysmem"
-        ],
-        "features": [],
-        "services": [
-            "fuchsia.mediacodec.CodecFactory",
-            "fuchsia.tracelink.Registry",
-            "fuchsia.sysmem.Allocator",
-            "fuchsia.logger.LogSink"
-        ]
-    }
-}
diff --git a/src/media/stream_processors/test/meta/h264_decoder_test_bin.cmx b/src/media/stream_processors/test/meta/h264_decoder_test.cmx
similarity index 93%
copy from src/media/stream_processors/test/meta/h264_decoder_test_bin.cmx
copy to src/media/stream_processors/test/meta/h264_decoder_test.cmx
index 1abfd5eb..619fbc3 100644
--- a/src/media/stream_processors/test/meta/h264_decoder_test_bin.cmx
+++ b/src/media/stream_processors/test/meta/h264_decoder_test.cmx
@@ -8,7 +8,7 @@
         }
     },
     "program": {
-        "binary": "test/h264_decoder_test_bin"
+        "binary": "test/h264_decoder_test"
     },
     "sandbox": {
         "dev": [
diff --git a/src/recovery/integration/BUILD.gn b/src/recovery/integration/BUILD.gn
index 09f8df4..e6f6fdd 100644
--- a/src/recovery/integration/BUILD.gn
+++ b/src/recovery/integration/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 import("//build/test/test_package.gni")
 import("//build/testing/environments.gni")
 
@@ -13,10 +13,8 @@
   ]
 }
 
-rustc_library("bin") {
-  testonly = true
-  with_unit_tests = true
-  name = "recovery_integration"
+rustc_test("bin") {
+  name = "recovery_integration_test"
   edition = "2018"
 
   deps = [
@@ -37,7 +35,7 @@
 
   tests = [
     {
-      name = "recovery_integration_lib_test"
+      name = "recovery_integration_test"
       environments = basic_envs
     },
   ]
diff --git a/src/recovery/integration/meta/recovery_integration_lib_test.cmx b/src/recovery/integration/meta/recovery_integration_test.cmx
similarity index 68%
rename from src/recovery/integration/meta/recovery_integration_lib_test.cmx
rename to src/recovery/integration/meta/recovery_integration_test.cmx
index 47c9021..2a93f2a 100644
--- a/src/recovery/integration/meta/recovery_integration_lib_test.cmx
+++ b/src/recovery/integration/meta/recovery_integration_test.cmx
@@ -1,6 +1,6 @@
 {
     "program": {
-        "binary": "test/recovery_integration_lib_test"
+        "binary": "test/recovery_integration_test"
     },
     "sandbox": {
         "services": [
diff --git a/src/recovery/system/BUILD.gn b/src/recovery/system/BUILD.gn
index 3535a70..8f4cada 100644
--- a/src/recovery/system/BUILD.gn
+++ b/src/recovery/system/BUILD.gn
@@ -73,7 +73,7 @@
 
 unittest_package("system_recovery_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/storage/ramdevice-client/BUILD.gn b/src/storage/ramdevice-client/BUILD.gn
index bc773d1..97ec511 100644
--- a/src/storage/ramdevice-client/BUILD.gn
+++ b/src/storage/ramdevice-client/BUILD.gn
@@ -19,7 +19,7 @@
 
 test_package("ramdevice-client-test") {
   deps = [
-    ":ramdevice-client",
+    ":ramdevice-client_test",
   ]
   tests = [
     {
diff --git a/src/sys/component_index/BUILD.gn b/src/sys/component_index/BUILD.gn
index c910bbd..3117364 100644
--- a/src/sys/component_index/BUILD.gn
+++ b/src/sys/component_index/BUILD.gn
@@ -57,7 +57,7 @@
 
 test_package("component_index_tests") {
   deps = [
-    ":component_index_bin",
+    ":component_index_bin_test",
   ]
 
   tests = [
diff --git a/src/sys/component_manager/BUILD.gn b/src/sys/component_manager/BUILD.gn
index f75ad39..356d3b3 100644
--- a/src/sys/component_manager/BUILD.gn
+++ b/src/sys/component_manager/BUILD.gn
@@ -97,7 +97,7 @@
 
 test_package("component_manager_tests") {
   deps = [
-    ":lib",
+    ":lib_test",
     "//examples/components/basic:hello_world_bin",
     "//src/lib/process_builder:root_job_test_runner",
     "//src/lib/process_builder:test_util",
diff --git a/src/sys/component_test_runner/BUILD.gn b/src/sys/component_test_runner/BUILD.gn
index aadc79f..e1f1d52 100644
--- a/src/sys/component_test_runner/BUILD.gn
+++ b/src/sys/component_test_runner/BUILD.gn
@@ -50,7 +50,7 @@
 
 test_package("component_test_runner_tests") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/src/sys/dash/BUILD.gn b/src/sys/dash/BUILD.gn
index 75d1e9c..a09e2a0 100644
--- a/src/sys/dash/BUILD.gn
+++ b/src/sys/dash/BUILD.gn
@@ -18,7 +18,6 @@
 
 rustc_binary("dash_test_bin") {
   name = "dash_test"
-  with_unit_tests = true
   edition = "2018"
   source_root = "src/integration_test.rs"
   deps = [
diff --git a/src/sys/lib/fuchsia_url/BUILD.gn b/src/sys/lib/fuchsia_url/BUILD.gn
index 26b823e..344a444 100644
--- a/src/sys/lib/fuchsia_url/BUILD.gn
+++ b/src/sys/lib/fuchsia_url/BUILD.gn
@@ -22,7 +22,7 @@
 
 test_package("fuchsia_url_tests") {
   deps = [
-    ":fuchsia_url",
+    ":fuchsia_url_test",
   ]
 
   tests = [
diff --git a/src/sys/lib/fuchsia_url_rewrite/BUILD.gn b/src/sys/lib/fuchsia_url_rewrite/BUILD.gn
index bd842ba..8485aff 100644
--- a/src/sys/lib/fuchsia_url_rewrite/BUILD.gn
+++ b/src/sys/lib/fuchsia_url_rewrite/BUILD.gn
@@ -25,7 +25,7 @@
 
 test_package("fuchsia_url_rewrite_tests") {
   deps = [
-    ":fuchsia_url_rewrite",
+    ":fuchsia_url_rewrite_test",
   ]
 
   tests = [
diff --git a/src/sys/locate/BUILD.gn b/src/sys/locate/BUILD.gn
index 9f6e5a6..6cc3865c 100644
--- a/src/sys/locate/BUILD.gn
+++ b/src/sys/locate/BUILD.gn
@@ -45,7 +45,6 @@
 
 rustc_binary("locate_integration_test_bin") {
   name = "locate_integration_test"
-  with_unit_tests = true
   edition = "2018"
   source_root = "src/locate_integration_test.rs"
   deps = [
diff --git a/src/ui/bin/shortcut/BUILD.gn b/src/ui/bin/shortcut/BUILD.gn
index eade99a..20be084 100644
--- a/src/ui/bin/shortcut/BUILD.gn
+++ b/src/ui/bin/shortcut/BUILD.gn
@@ -57,7 +57,7 @@
 
 test_package("shortcut_test") {
   deps = [
-    ":bin",
+    ":bin_test",
   ]
 
   tests = [
diff --git a/tools/banjo/banjo/BUILD.gn b/tools/banjo/banjo/BUILD.gn
index 6c320b8..b9bad503 100644
--- a/tools/banjo/banjo/BUILD.gn
+++ b/tools/banjo/banjo/BUILD.gn
@@ -6,6 +6,7 @@
 import("//build/package.gni")
 import("//build/rust/rustc_binary.gni")
 import("//build/rust/rustc_library.gni")
+import("//build/rust/rustc_test.gni")
 
 rustc_binary("banjo_bin") {
   edition = "2018"
@@ -42,10 +43,8 @@
 }
 
 if (host_toolchain == current_toolchain) {
-  rustc_library("banjo_unittests") {
+  rustc_test("banjo_unittests") {
     edition = "2018"
-    with_unit_tests = true
-    testonly = true
 
     deps = [
       ":banjo_bin",