diff --git a/zircon/public/gn/fidl.gni b/zircon/public/gn/fidl.gni
index b74543a7510028af622608a7914d8dfa0684118e..3d466c219e5f8514728a0ccb9bf40f1a88b5694e 100644
--- a/zircon/public/gn/fidl.gni
+++ b/zircon/public/gn/fidl.gni
@@ -147,6 +147,18 @@ template("fidl_library") {
   assert(defined(invoker.sources),
          "fidl_library(\"$target_name\") must set `sources`")
 
+  foreach(file, invoker.sources) {
+    assert(get_path_info(file, "extension") == "fidl",
+           "fidl_library() sources should be `.fidl` files, not $file")
+    file = get_path_info(file, "name")
+    if (get_path_info(file, "extension") == "test") {
+      assert(!defined(invoker.testonly) || invoker.testonly,
+             "fidl_library(\"$target_name\") is implicitly testonly since " +
+                 " it has `.test.fidl` sources; cannot use testonly=false!")
+      invoker.testonly = true
+    }
+  }
+
   fidl_target = target_name
 
   # TODO(mcgrathr): temporary until everything is renamed with . names