diff --git a/Devel.hs b/Devel.hs
--- a/Devel.hs
+++ b/Devel.hs
@@ -139,7 +139,7 @@
 checkCabalFile gpd = case D.condLibrary gpd of
     Nothing -> failWith "incorrect cabal file, no library"
     Just ct ->
-      case lookupDevelLib ct of
+      case lookupDevelLib gpd ct of
         Nothing   ->
           failWith "no development flag found in your configuration file. Expected a 'library-only' flag or the older 'devel' flag"
         Just dLib -> do
@@ -196,14 +196,13 @@
            | otherwise      = selectOpts opts (x2:xs)
         selectOpts _ _ = []
 
-lookupDevelLib :: D.CondTree D.ConfVar c a -> Maybe a
-lookupDevelLib ct | found     = Just (D.condTreeData ct)
-                  | otherwise = Nothing
+lookupDevelLib :: D.GenericPackageDescription -> D.CondTree D.ConfVar c a -> Maybe a
+lookupDevelLib gpd ct | found     = Just (D.condTreeData ct)
+                      | otherwise = Nothing
   where
-    found = not . null . map (\(_,x,_) -> D.condTreeData x) .
-            filter isDevelLib . D.condTreeComponents  $ ct
-    isDevelLib (D.Var (D.Flag (D.FlagName f)), _, _) = f `elem` ["library-only", "devel"]
-    isDevelLib _                                       = False
+    flags = map (unFlagName . D.flagName) $ D.genPackageFlags gpd
+    unFlagName (D.FlagName x) = x
+    found = any (`elem` ["library-only", "devel"]) flags
 
 -- | Acts like @rawSystem@, but filters out lines from the output that we're not interested in seeing.
 rawSystemFilter :: String -> [String] -> IO ExitCode
diff --git a/Scaffolding/Scaffolder.hs b/Scaffolding/Scaffolder.hs
--- a/Scaffolding/Scaffolder.hs
+++ b/Scaffolding/Scaffolder.hs
@@ -5,7 +5,6 @@
 import Scaffolding.CodeGen
 
 import Language.Haskell.TH.Syntax
-import Control.Monad (when)
 import qualified Data.Text.Lazy as LT
 import qualified Data.Text.Lazy.Encoding as LT
 import qualified Data.ByteString.Lazy as L
@@ -72,9 +71,6 @@
         uncapitalize s = toLower (head s) : tail s
         backendLower = uncapitalize $ show backend 
         upper = show backend
-    
-    let useTests = True
-    let testsDep = if useTests then ", yesod-test" else ""
 
     let runMigration  =
           case backend of
@@ -149,8 +145,6 @@
     writeFile' "main.hs" $(codegen "main.hs")
     writeFile' "devel.hs" $(codegen "devel.hs")
     writeFile' (project ++ ".cabal") $(codegen "project.cabal")
-    when useTests $
-      appendFile' (project ++ ".cabal") $(codegen "cabal_test_suite")
 
     writeFile' ".ghci" $(codegen ".ghci")
     writeFile' "LICENSE" $(codegen "LICENSE")
@@ -161,6 +155,7 @@
     writeFile' "Model.hs" $(codegen "Model.hs")
     writeFile' "Settings.hs" $(codegen "Settings.hs")
     writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs")
+    writeFile' "Settings/Development.hs" $(codegen "Settings/Development.hs")
     writeFile' "static/css/bootstrap.css"
         $(codegen "static/css/bootstrap.css")
     writeFile' "templates/default-layout.hamlet"
@@ -179,9 +174,9 @@
     writeFile' "config/models" $(codegen "config/models")
     writeFile' "messages/en.msg" $(codegen "messages/en.msg")
 
-    when useTests $ do
-      mkDir "tests"
-      writeFile' "tests/main.hs" $(codegen "tests/main.hs")
+    mkDir "tests"
+    writeFile' "tests/main.hs" $(codegen "tests/main.hs")
+    writeFile' "tests/HomeTest.hs" $(codegen "tests/HomeTest.hs")
 
     S.writeFile (dir ++ "/config/favicon.ico")
         $(runIO (S.readFile "scaffold/config/favicon.ico.cg") >>= \bs -> do
diff --git a/main.hs b/main.hs
--- a/main.hs
+++ b/main.hs
@@ -2,9 +2,10 @@
 
 import Scaffolding.Scaffolder
 import System.Environment (getArgs)
-import System.Exit (exitWith)
+import System.Exit (exitWith, ExitCode (ExitSuccess))
 import System.Process (rawSystem)
-import Yesod.Core(yesodVersion)
+import Yesod.Core (yesodVersion)
+import Control.Monad (unless)
 
 #ifndef WINDOWS
 import Build (touch)
@@ -36,6 +37,11 @@
         ["touch"] -> touch
 #endif
         "devel":rest -> devel isDev rest
+        "test":_ -> do
+            touch
+            rawSystem' cmd ["configure", "--enable-tests", "-flibrary-only"]
+            rawSystem' cmd ["build"]
+            rawSystem' cmd ["test"]
         ["version"] -> putStrLn $ "yesod-core version:" ++ yesodVersion
         "configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
         _ -> do
@@ -49,5 +55,12 @@
                 ++ windowsWarning
             putStrLn "    devel        Run project with the devel server"
             putStrLn "                    use --dev devel to build with cabal-dev"
+            putStrLn "    test         Build and run the integration tests"
+            putStrLn "                    use --dev devel to build with cabal-dev"
             putStrLn "    version      Print the version of Yesod"
 
+-- | Like @rawSystem@, but exits if it receives a non-success result.
+rawSystem' :: String -> [String] -> IO ()
+rawSystem' x y = do
+    res <- rawSystem x y
+    unless (res == ExitSuccess) $ exitWith res
diff --git a/scaffold/Application.hs.cg b/scaffold/Application.hs.cg
--- a/scaffold/Application.hs.cg
+++ b/scaffold/Application.hs.cg
@@ -2,6 +2,7 @@
 module Application
     ( makeApplication
     , getApplicationDev
+    , makeFoundation
     ) where
 
 import Import
@@ -10,13 +11,8 @@
 import Yesod.Default.Config
 import Yesod.Default.Main
 import Yesod.Default.Handlers
-#if DEVELOPMENT
-import Yesod.Logger (Logger, logBS)
-import Network.Wai.Middleware.RequestLogger (logCallbackDev)
-#else
 import Yesod.Logger (Logger, logBS, toProduction)
-import Network.Wai.Middleware.RequestLogger (logCallback)
-#endif
+import Network.Wai.Middleware.RequestLogger (logCallback, logCallbackDev)
 import qualified Database.Persist.Store~importMigration~
 import Network.HTTP.Conduit (newManager, def)
 
@@ -39,13 +35,9 @@
     app <- toWaiAppPlain foundation
     return $ logWare app
   where
-#ifdef DEVELOPMENT
-    logWare = logCallbackDev (logBS setLogger)
-    setLogger = logger
-#else
-    setLogger = toProduction logger -- by default the logger is set for development
-    logWare = logCallback (logBS setLogger)
-#endif
+    setLogger = if development then logger else toProduction logger
+    logWare   = if development then logCallbackDev (logBS setLogger)
+                               else logCallback    (logBS setLogger)
 
 makeFoundation :: AppConfig DefaultEnv Extra -> Logger -> IO ~sitearg~
 makeFoundation conf setLogger = do
diff --git a/scaffold/Import.hs.cg b/scaffold/Import.hs.cg
--- a/scaffold/Import.hs.cg
+++ b/scaffold/Import.hs.cg
@@ -3,6 +3,7 @@
     , module Yesod
     , module Foundation
     , module Settings.StaticFiles
+    , module Settings.Development
     , module Data.Monoid
     , module Control.Applicative
     , Text
@@ -18,6 +19,7 @@
 import Control.Applicative ((<$>), (<*>), pure)
 import Data.Text (Text)
 import Settings.StaticFiles
+import Settings.Development
 
 #if __GLASGOW_HASKELL__ < 704
 infixr 5 <>
diff --git a/scaffold/Settings.hs.cg b/scaffold/Settings.hs.cg
--- a/scaffold/Settings.hs.cg
+++ b/scaffold/Settings.hs.cg
@@ -21,6 +21,7 @@
 import Data.Text (Text)
 import Data.Yaml
 import Control.Applicative
+import Settings.Development
 
 -- | Which Persistent backend this site is using.
 type PersistConfig = ~configPersist~
@@ -53,11 +54,8 @@
 -- user.
 
 widgetFile :: String -> Q Exp
-#if DEVELOPMENT
-widgetFile = Yesod.Default.Util.widgetFileReload
-#else
-widgetFile = Yesod.Default.Util.widgetFileNoReload
-#endif
+widgetFile = if development then Yesod.Default.Util.widgetFileReload
+                            else Yesod.Default.Util.widgetFileNoReload
 
 data Extra = Extra
     { extraCopyright :: Text
diff --git a/scaffold/Settings/Development.hs.cg b/scaffold/Settings/Development.hs.cg
new file mode 100644
--- /dev/null
+++ b/scaffold/Settings/Development.hs.cg
@@ -0,0 +1,14 @@
+module Settings.Development where
+
+import Prelude
+
+development :: Bool
+development =
+#if DEVELOPMENT
+  True
+#else
+  False
+#endif
+
+production :: Bool
+production = not development
diff --git a/scaffold/Settings/StaticFiles.hs.cg b/scaffold/Settings/StaticFiles.hs.cg
--- a/scaffold/Settings/StaticFiles.hs.cg
+++ b/scaffold/Settings/StaticFiles.hs.cg
@@ -4,15 +4,12 @@
 import Yesod.Static
 import qualified Yesod.Static as Static
 import Settings (staticDir)
+import Settings.Development
 
 -- | use this to create your static file serving site
 staticSite :: IO Static.Static
-staticSite =
-#ifdef DEVELOPMENT
-  Static.staticDevel staticDir
-#else
-  Static.static staticDir
-#endif
+staticSite = if development then Static.staticDevel staticDir
+                            else Static.static      staticDir
 
 -- | This generates easy references to files in the static directory at compile time,
 --   giving you compile-time verification that referenced files exist.
diff --git a/scaffold/cabal_test_suite.cg b/scaffold/cabal_test_suite.cg
deleted file mode 100644
--- a/scaffold/cabal_test_suite.cg
+++ /dev/null
@@ -1,19 +0,0 @@
-test-suite integration-tests
-    type: exitcode-stdio-1.0
-    main-is:        main.hs
-    hs-source-dirs: tests .
-    ghc-options:     -Wall
-    extensions: TemplateHaskell
-                QuasiQuotes
-                OverloadedStrings
-                NoImplicitPrelude
-                CPP
-                OverloadedStrings
-                MultiParamTypeClasses
-                TypeFamilies
-                GADTs
-                GeneralizedNewtypeDeriving
-                FlexibleContexts
-
-    build-depends: base                          >= 4          && < 5
-                 , yesod-test                    >= 0.1        && < 0.2
diff --git a/scaffold/project.cabal.cg b/scaffold/project.cabal.cg
--- a/scaffold/project.cabal.cg
+++ b/scaffold/project.cabal.cg
@@ -8,7 +8,7 @@
 description:       I'm sure you can say something clever here if you try.
 category:          Web
 stability:         Experimental
-cabal-version:     >= 1.6
+cabal-version:     >= 1.8
 build-type:        Simple
 homepage:          http://~project~.yesodweb.com/
 
@@ -21,53 +21,26 @@
     Default:       False
 
 library
-    if flag(library-only)
-        Buildable: True
-    else
-        Buildable: False
-
     exposed-modules: Application
-    other-modules:   Foundation
+                     Foundation
                      Import
                      Model
                      Settings
                      Settings.StaticFiles
+                     Settings.Development
                      Handler.Home
 
-    ghc-options:   -Wall -threaded -O0
-    cpp-options:   -DDEVELOPMENT
-
-    extensions: TemplateHaskell
-                QuasiQuotes
-                OverloadedStrings
-                NoImplicitPrelude
-                CPP
-                MultiParamTypeClasses
-                TypeFamilies
-                GADTs
-                GeneralizedNewtypeDeriving
-                FlexibleContexts
-                EmptyDataDecls
-                NoMonomorphismRestriction
-
-executable         ~project~
-    if flag(library-only)
-        Buildable: False
-
-    if flag(dev)
+    if flag(dev) || flag(library-only)
         cpp-options:   -DDEVELOPMENT
         ghc-options:   -Wall -threaded -O0
     else
         ghc-options:   -Wall -threaded -O2
 
-    main-is:       main.hs
-
     extensions: TemplateHaskell
                 QuasiQuotes
                 OverloadedStrings
                 NoImplicitPrelude
                 CPP
-                OverloadedStrings
                 MultiParamTypeClasses
                 TypeFamilies
                 GADTs
@@ -103,4 +76,35 @@
                  , directory                     >= 1.1        && < 1.2
                  , warp                          >= 1.2        && < 1.3
 
-                 ~testsDep~
+executable         ~project~
+    if flag(library-only)
+        Buildable: False
+
+    main-is:           ../main.hs
+    hs-source-dirs:    dist
+    build-depends:     base
+                     , ~project~
+                     , yesod-default
+
+test-suite test
+    type:              exitcode-stdio-1.0
+    main-is:           main.hs
+    hs-source-dirs:    tests
+    ghc-options:       -Wall
+    extensions:        TemplateHaskell
+                       QuasiQuotes
+                       OverloadedStrings
+                       NoImplicitPrelude
+                       CPP
+                       OverloadedStrings
+                       MultiParamTypeClasses
+                       TypeFamilies
+                       GADTs
+                       GeneralizedNewtypeDeriving
+                       FlexibleContexts
+
+    build-depends: base
+                 , ~project~
+                 , yesod-test
+                 , yesod-default
+                 , yesod-core
diff --git a/scaffold/templates/homepage.hamlet.cg b/scaffold/templates/homepage.hamlet.cg
--- a/scaffold/templates/homepage.hamlet.cg
+++ b/scaffold/templates/homepage.hamlet.cg
@@ -2,14 +2,14 @@
 
 <ol>
   <li>Now that you have a working project you should use the #
-    <a href="http://www.yesodweb.com/book/">Yesod book</a> to learn more. #
+    \<a href="http://www.yesodweb.com/book/">Yesod book</a> to learn more. #
     You can also use this scaffolded site to explore some basic concepts.
 
   <li> This page was generated by the #{handlerName} handler in #
-    <em>Handler/Root.hs</em>.
+    \<em>Handler/Root.hs</em>.
 
   <li> The #{handlerName} handler is set to generate your site's home screen in Routes file #
-    <em>config/routes</em>
+    <em>config/routes
 
   <li> The HTML you are seeing now is actually composed by a number of <em>widgets</em>, #
     most of them are brought together by the <em>defaultLayout</em> function which #
@@ -18,13 +18,13 @@
 
   <li>
     A Widget's Html, Css and Javascript are separated in three files with the #
-    <em>.hamlet</em>, <em>.lucius</em> and <em>.julius</em> extensions. 
+    \<em>.hamlet</em>, <em>.lucius</em> and <em>.julius</em> extensions. 
 
   <li ##{aDomId}>If you had javascript enabled then you wouldn't be seeing this.
     
   <li #form>
     This is an example trivial Form. Read the #
-    <a href="http://www.yesodweb.com/book/forms">Forms chapter</a> #
+    \<a href="http://www.yesodweb.com/book/forms">Forms chapter</a> #
     on the yesod book to learn more about them.
     $maybe (info,con) <- submission
       <div .message>
@@ -35,4 +35,4 @@
 
   <li> And last but not least, Testing. In <em>tests/main.hs</em> you will find a #
     test suite that performs tests on this page. #
-    You can run your tests by doing: <pre>cabal install --enable-tests && cabal test</pre>
+    You can run your tests by doing: <pre>yesod test</pre>
diff --git a/scaffold/tests/HomeTest.hs.cg b/scaffold/tests/HomeTest.hs.cg
new file mode 100644
--- /dev/null
+++ b/scaffold/tests/HomeTest.hs.cg
@@ -0,0 +1,24 @@
+module HomeTest
+    ( homeSpecs
+    ) where
+
+import Import
+import Yesod.Test
+
+homeSpecs :: Specs
+homeSpecs =
+  describe "These are some example tests" $
+    it "loads the index and checks it looks right" $ do
+      get_ "/"
+      statusIs 200
+      htmlAllContain "h1" "Hello"
+
+      post "/" $ do
+        addNonce
+        fileByLabel "Choose a file" "tests/main.hs" "text/plain" -- talk about self-reference
+        byLabel "What's on the file?" "Some Content"
+
+      statusIs 200
+      htmlCount ".message" 1
+      htmlAllContain ".message" "Some Content"
+      htmlAllContain ".message" "text/plain"
diff --git a/scaffold/tests/main.hs.cg b/scaffold/tests/main.hs.cg
--- a/scaffold/tests/main.hs.cg
+++ b/scaffold/tests/main.hs.cg
@@ -11,6 +11,8 @@
 import Yesod.Test
 import Application (makeFoundation)
 
+import HomeTest
+
 main :: IO a
 main = do
     conf <- loadConfig $ (configSettings Testing) { csParseExtra = parseExtra }
diff --git a/yesod.cabal b/yesod.cabal
--- a/yesod.cabal
+++ b/yesod.cabal
@@ -1,5 +1,5 @@
 name:            yesod
-version:         1.0.1.2
+version:         1.0.1.3
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <michael@snoyman.com>
@@ -27,11 +27,12 @@
   scaffold/postgresqlConnPool.cg
   scaffold/Foundation.hs.cg
   scaffold/sqliteConnPool.cg
-  scaffold/cabal_test_suite.cg
   scaffold/Import.hs.cg
   scaffold/.ghci.cg
   scaffold/tests/main.hs.cg
+  scaffold/tests/HomeTest.hs.cg
   scaffold/Settings.hs.cg
+  scaffold/Settings/Development.hs.cg
   scaffold/Settings/StaticFiles.hs.cg
   scaffold/Application.hs.cg
   scaffold/deploy/Procfile.cg
