def METHOD_NAME(
        name,
        srcs,
        deps = [],
        defs = [],
        enable_nullability = False,
        main_class = None,
        closure_defines = dict(),
        suppress = [],
        tags = [],
        **kwargs):
    """Macro that turns Java files into integration test targets.
    deps are Labels of j2cl_library() rules. NOT labels of
    java_library() rules.
    """
    # figure out the current location
    java_package = get_java_package(native.package_name())
    if not main_class:
        main_class = java_package + ".Main"
    define_flags = ["--define=%s=%s" % (k, v) for (k, v) in closure_defines.items()]
    defs = defs + define_flags
    java_test_runner = """
      @jsinterop.annotations.JsType(namespace = jsinterop.annotations.JsPackage.GLOBAL)
      public class TestRunner {
        public static void testMain() throws Throwable {
          %s.main((String []) null);
        }
      }
    """ % (main_class)
    _genfile("TestRunner.java", java_test_runner, tags)
    j2cl_library(
        name = "%s-TestRunner" % name,
        srcs = ["TestRunner.java"],
        generate_build_test = False,
        deps = [
            ":%s-j2cl" % name,
            "//third_party:gwt-jsinterop-annotations-j2cl",
        ],
        javacopts = JAVAC_FLAGS,
        tags = tags,
    )
    integration_library(
        name = name,
        srcs = srcs,
        deps = deps,
        tags = tags,
        js_suppress = suppress,
        enable_nullability = enable_nullability,
    )
    # blaze test :uncompiled_test
    # blaze test :compiled_test
    test_harness = """
      goog.module('gen.test.Harness');
      goog.setTestOnly();
      var testSuite = goog.require('goog.testing.testSuite');
      var TestRunner = goog.require('TestRunner');
      testSuite({ testJ2cl: TestRunner.testMain });
    """
    _genfile("TestHarness_test.js", test_harness, tags)
    closure_js_test(
        name = "compiled_test",
        srcs = ["TestHarness_test.js"],
        deps = [
            ":%s-j2cl" % name,
            ":%s-TestRunner" % name,
            "@com_google_javascript_closure_library//closure/goog/testing:testsuite",
        ],
        # closure_js_test test infra is flaky so avoid noise in builds.
        flaky = True,
        defs = J2CL_TEST_DEFS + defs,
        suppress = suppress,
        testonly = True,
        tags = tags,
        entry_points = ["gen.test.Harness"],
    )