@@ -692,6 +692,7 @@ Task createXbuildTask(String taskName, String taskDescription,
692
692
sprintf (" /property:OutputPath=%s%s" ,
693
693
binaryOutputDir. absolutePath,
694
694
File . separator),
695
+ " /verbosity:quiet" ,
695
696
projectToBuild. absolutePath])
696
697
}
697
698
task. ext. buildDir = outputDir
@@ -1017,13 +1018,16 @@ Task createSetupUnityProjectTask(String taskName, Iterable<Task> dependsOn,
1017
1018
* @param additionalArguments Additional arguments to pass to Unity when
1018
1019
* executing the test.
1019
1020
* @param batchMode Whether to execute Unity in batch mode.
1021
+ * @param editorAssets Files to copy into the Assets/Editor folder in the
1022
+ * project.
1020
1023
* @param createTaskClosure Optional task used to start Unity, this must
1021
1024
* conform to tasks.create(name, description, type, dependsOn).
1022
1025
*
1023
1026
* @returns Test task.
1024
1027
*/
1025
1028
Task createUnityTestTask (String taskName , String description ,
1026
1029
Iterable<Task > dependsOn , File testScriptsDir ,
1030
+ Iterable<File > editorAssets ,
1027
1031
Iterable<String > additionalArguments ,
1028
1032
Boolean batchMode , createTaskClosure ) {
1029
1033
List<File > inputFiles = fileTree(testScriptsDir). collect {
@@ -1043,8 +1047,22 @@ Task createUnityTestTask(String taskName, String description,
1043
1047
inputFiles, testScriptsDir, setupTestProject. ext. projectDir,
1044
1048
[setupTestProject], null )
1045
1049
1050
+ // Task which copies editor scripts into the project.
1051
+ Task copyEditorAssets = tasks. create(
1052
+ name : sprintf (" copyEditorAssetsFor%s" , taskName),
1053
+ description : sprintf (" Copy the editor assets into the %s Unity project." ,
1054
+ taskName),
1055
+ type : Copy ,
1056
+ dependsOn : [setupTestProject])
1057
+ copyEditorAssets. with {
1058
+ from editorAssets
1059
+ into new File (new File (setupTestProject. ext. projectDir, " Assets" ),
1060
+ " Editor" )
1061
+ }
1062
+
1046
1063
// Create the test task.
1047
- Task testTask = createUnityTask(taskName, " test" , [copyTestScripts],
1064
+ Task testTask = createUnityTask(taskName, " test" ,
1065
+ [copyTestScripts, copyEditorAssets],
1048
1066
setupTestProject. ext. projectDir. name,
1049
1067
setupTestProject. ext. containerDir,
1050
1068
additionalArguments, batchMode,
@@ -1070,6 +1088,8 @@ Task createUnityTestTask(String taskName, String description,
1070
1088
* @param dependsOn Dependencies of the new task.
1071
1089
* @param testScriptsDir Directory containing scripts to copy into the test
1072
1090
* project and execute for testing.
1091
+ * @param editorAssets Files to copy into the Assets/Editor folder in the
1092
+ * project.
1073
1093
* @param additionalArguments Additional arguments to pass to Unity.
1074
1094
* @param createTaskClosure Optional task used to start Unity, this must
1075
1095
* conform to tasks.create(name, description, type, dependsOn).
@@ -1079,6 +1099,7 @@ Task createUnityTestTask(String taskName, String description,
1079
1099
Task createUnityTestBatchAndNonBatch (String taskName , String description ,
1080
1100
Iterable<Task > dependsOn ,
1081
1101
File testScriptsDir ,
1102
+ Iterable<File > editorAssets ,
1082
1103
Iterable<String > additionalArguments ,
1083
1104
createTaskClosure ) {
1084
1105
return tasks. create(name : taskName,
@@ -1087,13 +1108,13 @@ Task createUnityTestBatchAndNonBatch(String taskName, String description,
1087
1108
createUnityTestTask(
1088
1109
sprintf (" %sBatchMode" , taskName),
1089
1110
sprintf (" %s (Batch Mode)" , description),
1090
- dependsOn, testScriptsDir, additionalArguments, true ,
1091
- createTaskClosure),
1111
+ dependsOn, testScriptsDir, editorAssets ,
1112
+ additionalArguments, true , createTaskClosure),
1092
1113
createUnityTestTask(
1093
1114
sprintf (" %sInteractiveMode" , taskName),
1094
1115
sprintf (" %s (Interactive Mode)" , description),
1095
- dependsOn, testScriptsDir, additionalArguments, false ,
1096
- createTaskClosure)])
1116
+ dependsOn, testScriptsDir, editorAssets ,
1117
+ additionalArguments, false , createTaskClosure)])
1097
1118
}
1098
1119
1099
1120
Task compileResolverLibTests = createXbuildTask(
@@ -1649,15 +1670,19 @@ createUnityTestBatchAndNonBatch(
1649
1670
(" Imports the plugin into a Unity project and verifies all " +
1650
1671
" components can be activated by the Version Handler." ),
1651
1672
[buildPlugin],
1652
- new File (project. ext. scriptDirectory," source/VersionHandlerImpl/test/activation" ), [], null )
1673
+ new File (project. ext. scriptDirectory,
1674
+ " source/VersionHandlerImpl/test/activation" ),
1675
+ [], [], null )
1653
1676
1654
1677
// Launch the test via a script that runs a local web server.
1655
1678
createUnityTestBatchAndNonBatch(
1656
1679
" testVersionHandlerWebRequest" ,
1657
1680
(" Imports the plugin into a Unity project tests the PortableWebRequest " +
1658
1681
" class." ),
1659
1682
[buildPlugin],
1660
- new File (project. ext. scriptDirectory, " source/VersionHandlerImpl/test/webrequest" ), [],
1683
+ new File (project. ext. scriptDirectory,
1684
+ " source/VersionHandlerImpl/test/webrequest" ),
1685
+ [], [],
1661
1686
{ String name, String description, Iterable<Task > depends,
1662
1687
File executable, Iterable<String > args ->
1663
1688
Iterable<String > runnerArgs = [executable. absolutePath] + args
@@ -1678,7 +1703,11 @@ createUnityTestBatchAndNonBatch(
1678
1703
(" Imports the plugin into a Unity project and tests reflection " +
1679
1704
" methods." ),
1680
1705
[buildPlugin],
1681
- new File (project. ext. scriptDirectory, " source/VersionHandler/test/reflection" ), [], null )
1706
+ new File (project. ext. scriptDirectory,
1707
+ " source/VersionHandler/test/reflection" ),
1708
+ [],
1709
+ [],
1710
+ null )
1682
1711
1683
1712
Task compileIntegrationTester = createXbuildTask(
1684
1713
" compileIntegrationTester" ,
@@ -1692,14 +1721,66 @@ Task compileIntegrationTester = createXbuildTask(
1692
1721
new File (" Google.IntegrationTester.dll.mdb" )],
1693
1722
[compileVersionHandler])
1694
1723
1695
- createUnityTestBatchAndNonBatch(
1696
- " testAndroidResolverAsyncResolve" ,
1724
+ /*
1725
+ * Creates a task which compiles and run a Unity integration test.
1726
+ *
1727
+ * @param taskName Name of the test.
1728
+ * @param description Description of the task.
1729
+ * @param dependsOn Dependencies of the new task.
1730
+ * @param integrationTestProject Project within
1731
+ * project.ext.pluginSolutionFile that contains the integration test.
1732
+ * @param integrationTestProjectSources Source files integrationTestProject
1733
+ * requires.
1734
+ * @param integrationTestProjectOutputs Assemblies generated by the
1735
+ * integrationTestProject.
1736
+ * @param unityProjectDir Directory containing a assets to copy into the
1737
+ * integration test project.
1738
+ * @param arguments Additional arguments for Unity when running the integration
1739
+ * test.
1740
+ */
1741
+ Task createUnityIntegrationTest (String taskName ,
1742
+ String description ,
1743
+ Iterable<Task > dependsOn ,
1744
+ String integrationTestProject ,
1745
+ Iterable<File > integrationTestProjectSources ,
1746
+ Iterable<File > integrationTestProjectOutputs ,
1747
+ File unityProjectDir ,
1748
+ Iterable<String > arguments ) {
1749
+ Task compileIntegrationTest = createXbuildTask(
1750
+ sprintf (" compile%s" , integrationTestProject),
1751
+ sprintf (" Compile %s for %s" , integrationTestProject, taskName),
1752
+ project. ext. pluginSolutionFile,
1753
+ integrationTestProject,
1754
+ integrationTestProjectSources,
1755
+ new File (project. ext. buildDir, integrationTestProject),
1756
+ integrationTestProjectOutputs,
1757
+ [compileIntegrationTester] + dependsOn)
1758
+
1759
+ createUnityTestBatchAndNonBatch(
1760
+ taskName,
1761
+ description,
1762
+ [buildPlugin],
1763
+ unityProjectDir,
1764
+ compileIntegrationTest. outputs. files +
1765
+ compileIntegrationTester. outputs. files,
1766
+ arguments, null )
1767
+ }
1768
+
1769
+ createUnityIntegrationTest(
1770
+ " testAndroidResolverIntegrationTests" ,
1697
1771
(" Imports the plugin into a Unity project, runs Android resolution with " +
1698
1772
" a combination of dependencies added via the programmatic API and via " +
1699
1773
" XML files, verifying all dependencies resolve successfully." ),
1700
- [buildPlugin],
1701
- new File (project. ext. scriptDirectory, " source/AndroidResolver/test/resolve_async" ),
1702
- [" -buildTarget" , " android" ], null ) // TODO: Move this into the test!?
1774
+ [compileAndroidResolver],
1775
+ " AndroidResolverIntegrationTests" ,
1776
+ fileTree(new File (new File (project. ext. pluginSourceDir, " AndroidResolver" ),
1777
+ " test" )),
1778
+ [new File (" Google.AndroidResolverIntegrationTests.dll" ),
1779
+ new File (" Google.AndroidResolverIntegrationTests.dll.mdb" )],
1780
+ new File (
1781
+ project. ext. scriptDirectory,
1782
+ " source/AndroidResolver/test/AndroidResolverIntegrationTestsUnityProject" ),
1783
+ [" -buildTarget" , " android" ])
1703
1784
1704
1785
task cleanTests (type : Delete ) {
1705
1786
description " Clean test directories."
0 commit comments