diff --git a/lib/spack/spack/hash_types.py b/lib/spack/spack/hash_types.py
index c1e25198cb3242621354f056b3a04d78a6c82c67..737678bd6d7582ac3992555ae7f8d77a13ba877a 100644
--- a/lib/spack/spack/hash_types.py
+++ b/lib/spack/spack/hash_types.py
@@ -39,7 +39,7 @@ def __call__(self, spec):
 
 
 #: Spack's deployment hash. Includes all inputs that can affect how a package is built.
-dag_hash = SpecHashDescriptor(depflag=dt.BUILD | dt.LINK | dt.RUN, package_hash=True, name="hash")
+dag_hash = SpecHashDescriptor(depflag=dt.BUILD | dt.LINK | dt.RUN | dt.TEST, package_hash=True, name="hash")
 
 
 #: Hash descriptor used only to transfer a DAG, as is, across processes