diff --git a/plugins/autotest/autotestplugin.cpp b/plugins/autotest/autotestplugin.cpp
index 525f21ae3e1b0526e9eeb28b02166f197a97a2be..9c32e0b75c252c2d5a2e21e6eaa52d2658c3b0e9 100644
--- a/plugins/autotest/autotestplugin.cpp
+++ b/plugins/autotest/autotestplugin.cpp
@@ -168,7 +168,7 @@ void AutotestPlugin::onRunAllTriggered()
     TestRunner *runner = TestRunner::instance();
     TestTreeModel *model = TestTreeModel::instance();
     runner->setSelectedTests(model->getAllTestCases());
-    runner->runTests();
+    runner->prepareToRunTests();
 }
 
 void AutotestPlugin::onRunSelectedTriggered()
@@ -176,7 +176,7 @@ void AutotestPlugin::onRunSelectedTriggered()
     TestRunner *runner = TestRunner::instance();
     TestTreeModel *model = TestTreeModel::instance();
     runner->setSelectedTests(model->getSelectedTests());
-    runner->runTests();
+    runner->prepareToRunTests();
 }
 
 void AutotestPlugin::updateMenuItemsEnabledState()
diff --git a/plugins/autotest/testnavigationwidget.cpp b/plugins/autotest/testnavigationwidget.cpp
index da0de8a76193cb77155ecc23ca99d526f3b1e42e..9745e1a19b38a32f03a01a3c0ba2006feeae3478 100644
--- a/plugins/autotest/testnavigationwidget.cpp
+++ b/plugins/autotest/testnavigationwidget.cpp
@@ -249,7 +249,7 @@ void TestNavigationWidget::onRunThisTestTriggered()
         if (TestConfiguration *configuration = m_model->getTestConfiguration(item)) {
             TestRunner *runner = TestRunner::instance();
             runner->setSelectedTests( {configuration} );
-            runner->runTests();
+            runner->prepareToRunTests();
         }
     }
 }
diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp
index 9ebb1c09fbb636c285a7c016b2c2ec85d32d1bcf..db78e24cd60b21b9f87153b99d1bafd2958b713f 100644
--- a/plugins/autotest/testresultspane.cpp
+++ b/plugins/autotest/testresultspane.cpp
@@ -288,14 +288,14 @@ void TestResultsPane::onRunAllTriggered()
 {
     TestRunner *runner = TestRunner::instance();
     runner->setSelectedTests(TestTreeModel::instance()->getAllTestCases());
-    runner->runTests();
+    runner->prepareToRunTests();
 }
 
 void TestResultsPane::onRunSelectedTriggered()
 {
     TestRunner *runner = TestRunner::instance();
     runner->setSelectedTests(TestTreeModel::instance()->getSelectedTests());
-    runner->runTests();
+    runner->prepareToRunTests();
 }
 
 void TestResultsPane::initializeFilterMenu()
diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp
index bc246ed6aac86db04ccabe584bcccd640ae15ced..b556989d625286113ea0a755f06c0970c0b4ce4a 100644
--- a/plugins/autotest/testrunner.cpp
+++ b/plugins/autotest/testrunner.cpp
@@ -86,7 +86,6 @@ TestRunner *TestRunner::instance()
 
 TestRunner::TestRunner(QObject *parent) :
     QObject(parent),
-    m_building(false),
     m_executingTests(false)
 {
 }
@@ -197,12 +196,9 @@ void performTestRun(QFutureInterface<void> &futureInterface,
     futureInterface.setProgressValue(testCaseCount);
 }
 
-void TestRunner::runTests()
+void TestRunner::prepareToRunTests()
 {
-    const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
-    const int timeout = settings->timeout;
-    const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
-    const bool displayRunConfigWarnings = !settings->omitRunConfigWarn;
+    const bool omitRunConfigWarnings = AutotestPlugin::instance()->settings()->omitRunConfigWarn;
 
     m_executingTests = true;
     emit testRunStarted();
@@ -211,7 +207,7 @@ void TestRunner::runTests()
     TestResultsPane::instance()->clearContents();
 
     foreach (TestConfiguration *config, m_selectedTests) {
-        if (displayRunConfigWarnings && config->guessedConfiguration()) {
+        if (!omitRunConfigWarnings && config->guessedConfiguration()) {
             TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
                 tr("Project's run configuration was guessed for \"%1\".\n"
                 "This might cause trouble during execution.").arg(config->displayName())));
@@ -237,38 +233,31 @@ void TestRunner::runTests()
 
     ProjectExplorer::Internal::ProjectExplorerSettings projectExplorerSettings =
         ProjectExplorer::ProjectExplorerPlugin::projectExplorerSettings();
-    if (projectExplorerSettings.buildBeforeDeploy) {
-        if (!project->hasActiveBuildSettings()) {
+    if (!projectExplorerSettings.buildBeforeDeploy) {
+        runTests();
+    } else {
+        if (project->hasActiveBuildSettings()) {
+            buildProject(project);
+        } else {
             TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
                 tr("Project is not configured. Canceling test run.")));
             onFinished();
             return;
         }
-
-        auto connection = connect(this, &TestRunner::requestStopTestRun, [&] () {
-            ProjectExplorer::BuildManager::instance()->cancel();
-            m_building = false;
-            m_buildSucceeded = false;
-        });
-        buildProject(project);
-        while (m_building) {
-            qApp->processEvents();
-        }
-        disconnect(connection);
-
-        if (!m_buildSucceeded) {
-            TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
-                tr("Build failed. Canceling test run.")));
-            onFinished();
-            return;
-        }
     }
+}
+
+void TestRunner::runTests()
+{
+    const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
+    const QString &metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
 
     connect(this, &TestRunner::testResultCreated,
             TestResultsPane::instance(), &TestResultsPane::addTestResult,
             Qt::QueuedConnection);
 
-    QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, timeout, metricsOption, this);
+    QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, settings->timeout,
+                                             metricsOption, this);
     Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"),
                                                                     Autotest::Constants::TASK_INDEX);
     connect(progress, &Core::FutureProgress::finished,
@@ -277,9 +266,9 @@ void TestRunner::runTests()
 
 void TestRunner::buildProject(ProjectExplorer::Project *project)
 {
-    m_building = true;
-    m_buildSucceeded = false;
     ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
+    m_buildConnect = connect(this, &TestRunner::requestStopTestRun,
+                             buildManager, &ProjectExplorer::BuildManager::cancel);
     connect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished,
             this, &TestRunner::buildFinished);
     ProjectExplorer::ProjectExplorerPlugin::buildProject(project);
@@ -287,11 +276,18 @@ void TestRunner::buildProject(ProjectExplorer::Project *project)
 
 void TestRunner::buildFinished(bool success)
 {
+    disconnect(m_buildConnect);
     ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
     disconnect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished,
                this, &TestRunner::buildFinished);
-    m_building = false;
-    m_buildSucceeded = success;
+
+    if (success) {
+        runTests();
+    } else {
+        TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
+            tr("Build failed. Canceling test run.")));
+        onFinished();
+    }
 }
 
 void TestRunner::onFinished()
diff --git a/plugins/autotest/testrunner.h b/plugins/autotest/testrunner.h
index ddbac5e92f7805da47d16d9f659c0987b40decc3..92de02f67b9946c8077a698c9510a3ecb5f4bf85 100644
--- a/plugins/autotest/testrunner.h
+++ b/plugins/autotest/testrunner.h
@@ -51,7 +51,7 @@ signals:
     void requestStopTestRun();
 
 public slots:
-    void runTests();
+    void prepareToRunTests();
 
 private slots:
     void buildProject(ProjectExplorer::Project *project);
@@ -59,13 +59,14 @@ private slots:
     void onFinished();
 
 private:
+    void runTests();
     explicit TestRunner(QObject *parent = 0);
 
     QList<TestConfiguration *> m_selectedTests;
-    bool m_building;
-    bool m_buildSucceeded;
     bool m_executingTests;
 
+    // temporarily used if building before running is necessary
+    QMetaObject::Connection m_buildConnect;
 };
 
 } // namespace Internal
diff --git a/shared/shared.pro b/shared/shared.pro
index e74d4d09acd4ebce498df7ef203d586a44c5a1db..541044da119bbc7f8c13743ed00e36e8a2224b20 100644
--- a/shared/shared.pro
+++ b/shared/shared.pro
@@ -1,10 +1,17 @@
+isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = $$(QTC_SOURCE)
+isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = $$(QTC_BUILD)
+isEmpty(IDE_SOURCE_TREE): error("Set QTC_SOURCE environment variable")
+isEmpty(IDE_BUILD_TREE): error("Set QTC_BUILD environment variable")
+
 TEMPLATE = aux
 
-content.files = \
-    autotest
+STATIC_BASE = $$PWD
+STATIC_DIRS = templates
 
-content.path = $$QTC_PREFIX/share/qtcreator/templates/wizards
+for(data_dir, STATIC_DIRS) {
+    files = $$files($$STATIC_BASE/$$data_dir/*, true)
+    for(file, files): !exists($$file/*): STATIC_FILES += $$file
+}
 
-OTHER_FILES += $${content.files}
+include($$IDE_SOURCE_TREE/share/qtcreator/static.pri)
 
-INSTALLS += content
diff --git a/shared/autotest/auto.pro b/shared/templates/wizards/autotest/auto.pro
similarity index 100%
rename from shared/autotest/auto.pro
rename to shared/templates/wizards/autotest/auto.pro
diff --git a/shared/autotest/autotest_24.png b/shared/templates/wizards/autotest/autotest_24.png
similarity index 100%
rename from shared/autotest/autotest_24.png
rename to shared/templates/wizards/autotest/autotest_24.png
diff --git a/shared/autotest/main.cpp b/shared/templates/wizards/autotest/main.cpp
similarity index 100%
rename from shared/autotest/main.cpp
rename to shared/templates/wizards/autotest/main.cpp
diff --git a/shared/autotest/src.pro b/shared/templates/wizards/autotest/src.pro
similarity index 100%
rename from shared/autotest/src.pro
rename to shared/templates/wizards/autotest/src.pro
diff --git a/shared/autotest/tests.pro b/shared/templates/wizards/autotest/tests.pro
similarity index 100%
rename from shared/autotest/tests.pro
rename to shared/templates/wizards/autotest/tests.pro
diff --git a/shared/autotest/tmp.pro b/shared/templates/wizards/autotest/tmp.pro
similarity index 100%
rename from shared/autotest/tmp.pro
rename to shared/templates/wizards/autotest/tmp.pro
diff --git a/shared/autotest/tst.pro b/shared/templates/wizards/autotest/tst.pro
similarity index 100%
rename from shared/autotest/tst.pro
rename to shared/templates/wizards/autotest/tst.pro
diff --git a/shared/autotest/tst_src.cpp b/shared/templates/wizards/autotest/tst_src.cpp
similarity index 100%
rename from shared/autotest/tst_src.cpp
rename to shared/templates/wizards/autotest/tst_src.cpp
diff --git a/shared/autotest/wizard.xml b/shared/templates/wizards/autotest/wizard.xml
similarity index 100%
rename from shared/autotest/wizard.xml
rename to shared/templates/wizards/autotest/wizard.xml