diff --git a/tensorflow/contrib/input_pipeline/BUILD b/tensorflow/contrib/input_pipeline/BUILD
index 777d66f6843..fa6b1cb69ed 100644
--- a/tensorflow/contrib/input_pipeline/BUILD
+++ b/tensorflow/contrib/input_pipeline/BUILD
@@ -72,6 +72,7 @@ py_test(
 )
 
 tf_cc_tests(
+    name = "input_pipeline_ops_test",
     size = "small",
     srcs = [
         "ops/input_pipeline_ops_test.cc",
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index 482be579f0d..4d6f8cf8571 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -1547,8 +1547,8 @@ cc_library(
     alwayslink = 1,
 )
 
-# Low level library tests
 tf_cc_tests(
+    name = "low_level_library_tests",
     size = "small",
     srcs = [
         "lib/core/arena_test.cc",
@@ -1621,7 +1621,8 @@ tf_cc_tests(
     ],
 )
 
-tf_cc_tests(
+tf_cc_test(
+    name = "platform_env_test",
     size = "small",
     srcs = ["platform/env_test.cc"],
     deps = [
@@ -1635,7 +1636,8 @@ tf_cc_tests(
     ],
 )
 
-tf_cc_tests(
+tf_cc_test(
+    name = "platform_file_system_test",
     size = "small",
     srcs = ["platform/file_system_test.cc"],
     deps = [
@@ -1686,8 +1688,8 @@ cc_test(
     ],
 )
 
-# higher level tests
 tf_cc_tests(
+    name = "higher_level_tests",
     size = "small",
     srcs = [
         "common_runtime/device_set_test.cc",
@@ -1783,8 +1785,8 @@ tf_cc_tests(
     ],
 )
 
-# GPU-related tests
 tf_cc_tests_gpu(
+    name = "gpu_related_tests",
     size = "small",
     srcs = glob(["user_ops/**/*_test.cc"]) + [
         "common_runtime/gpu/gpu_bfc_allocator_test.cc",
@@ -2231,6 +2233,7 @@ tf_cc_test(
 )
 
 tf_cc_tests(
+    name = "ops_tests",
     size = "small",
     srcs = [
         "ops/array_ops_test.cc",
diff --git a/tensorflow/core/distributed_runtime/BUILD b/tensorflow/core/distributed_runtime/BUILD
index 69102b97859..ddda8d07424 100644
--- a/tensorflow/core/distributed_runtime/BUILD
+++ b/tensorflow/core/distributed_runtime/BUILD
@@ -27,6 +27,7 @@ filegroup(
     ]),
 )
 
+load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test")
 load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_tests")
 
 # For platform specific build config
@@ -268,6 +269,7 @@ cc_library(
 # TODO(mrry): Move executor_test.cc to ../common_runtime when once it no longer depends
 # on grpc_testlib.
 tf_cuda_cc_tests(
+    name = "executor_tests",
     size = "medium",
     srcs = [
         "executor_test.cc",
@@ -303,11 +305,10 @@ tf_cuda_cc_tests(
     ],
 )
 
-tf_cuda_cc_tests(
+tf_cuda_cc_test(
+    name = "remote_device_test",
     size = "small",
-    srcs = [
-        "remote_device_test.cc",
-    ],
+    srcs = ["remote_device_test.cc"],
     linkstatic = tf_kernel_tests_linkstatic(),
     tags = tf_cuda_tests_tags() + ["manual"],
     deps = [
diff --git a/tensorflow/core/distributed_runtime/rpc/BUILD b/tensorflow/core/distributed_runtime/rpc/BUILD
index 22c58f55a3b..de48378f93d 100644
--- a/tensorflow/core/distributed_runtime/rpc/BUILD
+++ b/tensorflow/core/distributed_runtime/rpc/BUILD
@@ -30,6 +30,7 @@ load(
     "tf_cuda_library",
     "tf_cc_test",
 )
+load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test")
 load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_tests")
 
 # For platform specific build config
@@ -368,6 +369,7 @@ cc_library(
 )
 
 tf_cuda_cc_tests(
+    name = "rpc_tests",
     size = "small",
     srcs = [
         "grpc_channel_test.cc",
@@ -418,11 +420,10 @@ tf_cc_test(
     ],
 )
 
-tf_cuda_cc_tests(
+tf_cuda_cc_test(
+    name = "grpc_session_test",
     size = "medium",
-    srcs = [
-        "grpc_session_test.cc",
-    ],
+    srcs = ["grpc_session_test.cc"],
     linkstatic = tf_kernel_tests_linkstatic(),
     tags = tf_cuda_tests_tags() + ["manual"],
     deps = [
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index e99ed9dfa89..d556450e77b 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -1272,6 +1272,7 @@ tf_kernel_library(
 )
 
 tf_cc_tests(
+    name = "dynamic_op_test",
     size = "small",
     srcs = [
         "dynamic_partition_op_test.cc",
@@ -1556,6 +1557,7 @@ tf_kernel_library(
 )
 
 tf_cc_tests(
+    name = "eigen_test",
     size = "small",
     srcs = [
         "eigen_activations_test.cc",
@@ -1577,6 +1579,7 @@ tf_cc_tests(
 )
 
 tf_cc_tests(
+    name = "basic_ops_benchmark_test",
     size = "small",
     srcs = [
         "basic_ops_benchmark_test.cc",
@@ -1594,6 +1597,7 @@ tf_cc_tests(
 )
 
 tf_cc_tests(
+    name = "bonus_tests",
     srcs = [
         "adjust_contrast_op_test.cc",
         "colorspace_op_test.cc",
@@ -1735,6 +1739,7 @@ tf_kernel_library(
 )
 
 tf_cc_tests(
+    name = "bonus2_tests",
     size = "small",
     srcs = [
         "merge_v2_checkpoints_op_test.cc",
@@ -1913,6 +1918,7 @@ tf_kernel_library(
 )
 
 tf_cc_tests(
+    name = "bonus3_tests",
     size = "small",
     srcs = [
         "logging_ops_test.cc",
@@ -2100,6 +2106,7 @@ tf_cc_test(
 )
 
 tf_cc_tests(
+    name = "sparse_tests",
     size = "small",
     srcs = [
         "sparse_add_op_test.cc",
@@ -2919,6 +2926,7 @@ tf_kernel_library(
 )
 
 tf_cuda_cc_tests(
+    name = "sparse2_tests",
     size = "small",
     srcs = [
         "sparse_tensor_dense_matmul_op_test.cc",
diff --git a/tensorflow/core/util/ctc/BUILD b/tensorflow/core/util/ctc/BUILD
index 78d0bcc958c..6dfb0bd731f 100644
--- a/tensorflow/core/util/ctc/BUILD
+++ b/tensorflow/core/util/ctc/BUILD
@@ -63,6 +63,7 @@ cc_library(
 )
 
 tf_cc_tests(
+    name = "ctc_beam_search_test",
     size = "small",
     srcs = [
         "ctc_beam_search_test.cc",
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index 6cdd02bdcac..9e26b4c6540 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -352,7 +352,7 @@ def tf_cuda_cc_test(name, srcs, deps, tags=[], data=[], size="medium",
              args=args)
 
 # Create a cc_test for each of the tensorflow tests listed in "tests"
-def tf_cc_tests(srcs, deps, linkstatic=0, tags=[], size="medium",
+def tf_cc_tests(srcs, deps, name='', linkstatic=0, tags=[], size="medium",
                 args=None, linkopts=[]):
   for src in srcs:
     tf_cc_test(
@@ -365,12 +365,12 @@ def tf_cc_tests(srcs, deps, linkstatic=0, tags=[], size="medium",
         args=args,
         linkopts=linkopts)
 
-def tf_cc_tests_gpu(srcs, deps, linkstatic=0, tags=[], size="medium",
+def tf_cc_tests_gpu(srcs, deps, name='', linkstatic=0, tags=[], size="medium",
                     args=None):
   tf_cc_tests(srcs, deps, linkstatic, tags=tags, size=size, args=args)
 
 
-def tf_cuda_cc_tests(srcs, deps, tags=[], size="medium", linkstatic=0,
+def tf_cuda_cc_tests(srcs, deps, name='', tags=[], size="medium", linkstatic=0,
                      args=None, linkopts=[]):
   for src in srcs:
     tf_cuda_cc_test(
diff --git a/tensorflow/user_ops/BUILD b/tensorflow/user_ops/BUILD
index 89c8f02d11c..e8198efe2e5 100644
--- a/tensorflow/user_ops/BUILD
+++ b/tensorflow/user_ops/BUILD
@@ -9,7 +9,7 @@ licenses(["notice"])  # Apache 2.0
 
 exports_files(["LICENSE"])
 
-load("//tensorflow:tensorflow.bzl", "py_tests")
+load("//tensorflow:tensorflow.bzl", "tf_py_test")
 load("//tensorflow:tensorflow.bzl", "tf_custom_op_library")
 
 tf_custom_op_library(
@@ -17,7 +17,7 @@ tf_custom_op_library(
     srcs = ["ackermann_op.cc"],
 )
 
-py_tests(
+tf_py_test(
     name = "ackermann_test",
     size = "small",
     srcs = ["ackermann_test.py"],
@@ -30,7 +30,7 @@ tf_custom_op_library(
     srcs = ["duplicate_op.cc"],
 )
 
-py_tests(
+tf_py_test(
     name = "duplicate_op_test",
     size = "small",
     srcs = ["duplicate_op_test.py"],
@@ -43,7 +43,7 @@ tf_custom_op_library(
     srcs = ["invalid_op.cc"],
 )
 
-py_tests(
+tf_py_test(
     name = "invalid_op_test",
     size = "small",
     srcs = ["invalid_op_test.py"],