diff --git a/hspec-discover.cabal b/hspec-discover.cabal
--- a/hspec-discover.cabal
+++ b/hspec-discover.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:             hspec-discover
-version:          2.10.2
+version:          2.10.3
 license:          MIT
 license-file:     LICENSE
 copyright:        (c) 2012-2022 Simon Hengel
diff --git a/src/Test/Hspec/Discover/Run.hs b/src/Test/Hspec/Discover/Run.hs
--- a/src/Test/Hspec/Discover/Run.hs
+++ b/src/Test/Hspec/Discover/Run.hs
@@ -61,8 +61,8 @@
 mkSpecModule src conf nodes =
   ( "{-# LINE 1 " . shows src . " #-}\n"
   . showString "{-# LANGUAGE NoImplicitPrelude #-}\n"
-  . showString "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}\n"
-  . showString ("module " ++ moduleName ++ exports ++ " where\n")
+  . showString "{-# OPTIONS_GHC -w -Wall -fno-warn-warnings-deprecations #-}\n"
+  . showString ("module " ++ moduleName src conf ++" where\n")
   . importList nodes
   . showString "import Test.Hspec.Discover\n"
   . maybe driver driverWithFormatter (configFormatter conf)
@@ -71,11 +71,15 @@
   . formatSpecs nodes
   ) "\n"
   where
-    ifNoMain x y = if configNoMain conf then x else y
-    defaultModuleName = ifNoMain (pathToModule src) "Main"
-    moduleName = fromMaybe defaultModuleName (configModuleName conf)
-    exports = " (" ++ ifNoMain "" "main, " ++ "spec)"
-    driver = showString $ ifNoMain "" "main :: IO ()\nmain = hspec spec\n"
+    driver =
+        case configNoMain conf of
+          False ->
+              showString "main :: IO ()\n"
+            . showString "main = hspec spec\n"
+          True -> ""
+
+moduleName :: FilePath -> Config -> String
+moduleName src conf = fromMaybe (if configNoMain conf then pathToModule src else "Main") (configModuleName conf)
 
 -- | Derive module name from specified path.
 pathToModule :: FilePath -> String
diff --git a/test/Test/Hspec/Discover/RunSpec.hs b/test/Test/Hspec/Discover/RunSpec.hs
--- a/test/Test/Hspec/Discover/RunSpec.hs
+++ b/test/Test/Hspec/Discover/RunSpec.hs
@@ -17,8 +17,8 @@
       readFile "out" `shouldReturn` unlines [
           "{-# LINE 1 \"test/Spec.hs\" #-}"
         , "{-# LANGUAGE NoImplicitPrelude #-}"
-        , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"
-        , "module Main (main, spec) where"
+        , "{-# OPTIONS_GHC -w -Wall -fno-warn-warnings-deprecations #-}"
+        , "module Main where"
         , "import qualified FooSpec"
         , "import qualified Foo.BarSpec"
         , "import qualified Foo.Bar.BazSpec"
@@ -41,8 +41,8 @@
       readFile "out" `shouldReturn` unlines [
           "{-# LINE 1 \"test/Spec.hs\" #-}"
         , "{-# LANGUAGE NoImplicitPrelude #-}"
-        , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"
-        , "module Spec (spec) where"
+        , "{-# OPTIONS_GHC -w -Wall -fno-warn-warnings-deprecations #-}"
+        , "module Spec where"
         , "import qualified FooSpec"
         , "import qualified Foo.BarSpec"
         , "import qualified Foo.Bar.BazSpec"
@@ -65,8 +65,8 @@
       readFile "out" `shouldReturn` unlines [
           "{-# LINE 1 \"test/Spec.hs\" #-}"
         , "{-# LANGUAGE NoImplicitPrelude #-}"
-        , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"
-        , "module Main (main, spec) where"
+        , "{-# OPTIONS_GHC -w -Wall -fno-warn-warnings-deprecations #-}"
+        , "module Main where"
         , "import qualified SpecHook"
         , "import qualified FooSpec"
         , "import qualified Foo.SpecHook"
@@ -89,8 +89,8 @@
       readFile "out" `shouldReturn` unlines [
           "{-# LINE 1 \"test/Spec.hs\" #-}"
         , "{-# LANGUAGE NoImplicitPrelude #-}"
-        , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"
-        , "module Main (main, spec) where"
+        , "{-# OPTIONS_GHC -w -Wall -fno-warn-warnings-deprecations #-}"
+        , "module Main where"
         , "import Test.Hspec.Discover"
         , "main :: IO ()"
         , "main = hspec spec"
diff --git a/version.yaml b/version.yaml
--- a/version.yaml
+++ b/version.yaml
@@ -1,1 +1,1 @@
-&version 2.10.2
+&version 2.10.3
