Как я могу запустить локальный сервер (с помощью gulp) и запустить автотест на этом сервере в pom.xml

Я хочу запустить локальный сервер и запустить автотест по конфигурации в pom.xml файл, как показано ниже

<execution>
                    <id>Run GUI</id>
                    <phase>pre-integration-test</phase>
                    <configuration>
                        <target>
                            <exec executable="cmd.exe" dir="${project.basedir}\src\main\resources">
                                <arg value="/c"/>
                                <arg value="${project.basedir}\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\RunGUI.bat"/>
                            </exec>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
               </execution>
               <execution>
                    <id>Run AutoTestWB</id>
                    <phase>post-integration-test</phase>
                    <configuration>
                        <target>
                            <exec executable="cmd" dir="${project.basedir}/src/main/resources/webapp/test/AutoTestWB/ui5-automation-framework/UI5Example"
                                failonerror="true" osfamily="windows">
                                <arg line="/c node ..\protractor\bin\protractor conf.js" />
                            </exec>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
               </execution>

Выполнено первое выполнение и запущен сервер

     [exec]
C:\Users\*******\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources>gulp serve 
     [exec] [17:24:53] Using gulpfile ~\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources\gulpfile.js
     [exec] [17:24:53] Starting 'serve'...
     [exec] [17:24:53] Finished 'serve' after 165 ms
     [exec] [17:24:53] Starting 'preload'...
     [exec] [17:24:53] Starting 'minify-css'...
     [exec] [17:24:53] Finished 'minify-css' after 28 μs
     [exec] [17:24:53] Starting 'copy-file'...
     [exec] [17:24:53] Finished 'copy-file' after 1.3 ms
     [exec] [17:24:53] Finished 'clean' after 207 ms
     [exec] [17:24:53] Finished 'sass' after 232 ms
     [exec] [Browsersync] Access URLs:
     [exec]  -------------------------------------
     [exec]        Local: http://localhost:3000
     [exec]     External: http://172.16.6.241:3000
     [exec]  -------------------------------------
     [exec]           UI: http://localhost:3001
     [exec]  UI External: http://localhost:3001
     [exec]  -------------------------------------
     [exec] [Browsersync] Serving files from: webapp
     [exec] [17:25:28] SyntaxError in plugin "gulp-uglify-es"
     [exec] Message:
     [exec]     'return' outside of function
     [exec] Details:
     [exec]     filename: test\AutoTestWB\ui5-automation-framework\node_modules\mkdirp\bin\cmd.js
     [exec]     line: 13
     [exec]     col: 4
     [exec]     pos: 313
     [exec] 
     [exec] [17:25:28] gulp-ui5-preload number of files combined to preload file Component-preload.js:  523
     [exec] [17:25:28] Finished 'preload' after 35 s
     [exec] [17:25:28] Starting 'create-dist'...
     [exec] [17:25:28] Finished 'create-dist' after 2.3 μs

Но пока следующее выполнение ждет завершения первого; первый не отвечает.

Итак, я попытался остановить порт первым

 [exec] [17:25:28] gulp-ui5-preload number of files combined to preload file Component-preload.js:  523
 [exec] [17:25:28] Finished 'preload' after 35 s
 [exec] [17:25:28] Starting 'create-dist'...
 [exec] [17:25:28] Finished 'create-dist' after 2.3 μs
 [exec] Result: 1
 [INFO] Executed tasks
[INFO] 
[INFO] --- maven-antrun-plugin:1.6:run (Run AutoTestWB) @ SampleWorkbench ---
[INFO] Executing tasks

main:
     [exec] (node:828) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
     [exec] [17:30:16] I/launcher - Test Coverage:false
     [exec] [17:30:16] I/launcher - Running 1 instances of WebDriver
     [exec] [17:30:16] I/direct - Using ChromeDriver directly...
     [exec] Started
     [exec] Jasmine started
     [exec] F
     [exec]   FORMAT CONVERSATION
     [exec]     × Step 1: Navigate to Format Conversation tab
     [exec]       - Failed: No tab found!
     [exec] F    × Step 2: Click on Source format select box
     [exec]       - Failed: No tab found. The action failed!
     [exec] F    × Step 3: Choose Source format
     [exec]       - Failed: No tab found. The action failed!
     [exec] F    × Step 4: Enter value for Source content
     [exec]       - Failed: No view found. The action failed!
     [exec] F    × Step 5: Click on Target format select box
     [exec]       - Failed: No view found. The action failed!
     [exec] F    × Step 6: Choose Target format
     [exec]       - Failed: No view found. The action failed!
     [exec] F    × Step 7: Do Convert
     [exec]       - Failed: No tab found. The action failed!
     [exec] F    × Step 8: Result
     [exec]       - Failed: No element found!
     [exec] 

и следующее выполнение будет запущено, но оно завершится ошибкой, поскольку запускается этот автотест, для которого требуется сервер при первом выполнении.

Пожалуйста, помогите мне! Спасибо

1 ответ

Спасибо ребята! Я нашел решение своего вопроса в этом блоге http://avianey.blogspot.com/2012/12/maven-it-case-background-process.html

Большое спасибо, автор.

В моем pom.xml файл, я редактировал mvn clean install -P integration-tests к clean install -P integration-tests

Вот мой код

<profiles>
        <profile>
            <id>integration-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.12.2</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>start-third-parties</id>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <target>
                                        <exec executable="powershell.exe" dir="${project.basedir}\src\main\resources" spawn="true">
                                            <arg value="${project.basedir}\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\RunGUI.bat"/>
                                        </exec>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-third-parties</id>
                                <phase>post-integration-test</phase>
                                <configuration>
                                    <target>
                                        <exec executable="powershell.exe" dir="${project.basedir}\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\UI5Example" spawn="false">
                                            <arg value="${project.basedir}\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\RunAutoTestWB.bat"/>
                                        </exec>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                           </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

И результат

 --- frontend-maven-plugin:1.8.0:gulp (gulp build) @ SampleWorkbench ---
[INFO] Running 'gulp.js ' in C:\Users\**********\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources
[INFO] [15:53:51] Using gulpfile ~\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources\gulpfile.js
[INFO] [15:53:51] Starting 'default'...
[INFO] [15:53:51] Finished 'default' after 68 μs
[INFO] [15:53:51] Starting 'preload'...
[INFO] [15:53:51] Starting 'minify-css'...
[INFO] [15:53:51] Finished 'minify-css' after 4.3 μs
[INFO] [15:53:51] Starting 'copy-file'...
[INFO] [15:53:51] Finished 'copy-file' after 1.38 ms
[INFO] [15:53:51] Finished 'clean' after 25 ms
[INFO] [15:53:51] Finished 'sass' after 74 ms
[INFO] [15:54:23] SyntaxError in plugin "gulp-uglify-es"
[INFO] Message:
[INFO]     'return' outside of function
[INFO] Details:
[INFO]     filename: test\AutoTestWB\ui5-automation-framework\node_modules\mkdirp\bin\cmd.js
[INFO]     line: 13
[INFO]     col: 4
[INFO]     pos: 313
[INFO] 
[INFO] [15:54:23] gulp-ui5-preload number of files combined to preload file Component-preload.js:  523
[INFO] [15:54:23] Finished 'preload' after 33 s
[INFO] [15:54:23] Starting 'create-dist'...
[INFO] [15:54:23] Finished 'create-dist' after 2.3 μs
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ SampleWorkbench ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ SampleWorkbench ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 3 source files to C:\Users\*********\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ SampleWorkbench ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ SampleWorkbench ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ SampleWorkbench ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-bundle-plugin:4.2.1:bundle (default-bundle) @ SampleWorkbench ---
[INFO] 
[INFO] --- maven-antrun-plugin:1.6:run (start-third-parties) @ SampleWorkbench ---
[INFO] Executing tasks

main:
[INFO] Executed tasks
[INFO] 
[INFO] --- maven-failsafe-plugin:2.12.2:integration-test (default) @ SampleWorkbench ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-antrun-plugin:1.6:run (stop-third-parties) @ SampleWorkbench ---
[INFO] Executing tasks

main:
     [exec] =================== Started running Autotest ...    ==================
     [exec] 
     [exec] C:\Users\*******\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\UI5Example>node ..\protractor\bin\protractor conf.js 
     [exec] [15:54:28] I/launcher - Test Coverage:false
     [exec] [15:54:28] I/launcher - Running 1 instances of WebDriver
     [exec] [15:54:28] I/direct - Using ChromeDriver directly...
     [exec] C:\Users\*******\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\RunAutoTestWB.b
     [exec] at : (node:11592) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
     [exec] At line:1 char:1
     [exec] + C:\Users\*******\Desktop\BaseWB\SampleWorkbench\SampleWorkbe ...
     [exec] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     [exec]     + CategoryInfo          : NotSpecified: ((node:11592) [D...pdir() instead.:String) [], RemoteException
     [exec]     + FullyQualifiedErrorId : NativeCommandError
     [exec]  
     [exec] Started
     [exec] Jasmine started
     [exec] .
     [exec]   FORMAT CONVERSATION
     [exec]     √ Step 1: Navigate to Format Conversation tab
     [exec] .    √ Step 2: Click on Source format select box
     [exec] .    √ Step 3: Choose Source format
     [exec] .    √ Step 4: Enter value for Source content
     [exec] .    √ Step 5: Click on Target format select box
     [exec] .    √ Step 6: Choose Target format
     [exec] .    √ Step 7: Do Convert
     [exec] .    √ Step 8: Result
     [exec] 
     [exec] 
     [exec] 
     [exec] 
     [exec] 8 specs, 0 failures
     [exec] Finished in 88.925 seconds
     [exec] 
     [exec] Executed 8 of 8 specs SUCCESS.
     [exec] [15:55:59] I/launcher - 0 instance(s) of WebDriver still running
     [exec] [15:55:59] I/launcher - chrome #01 passed
     [exec] 
     [exec] C:\Users\*******.'js' is not recognized as an internal or external command,
     [exec] operable program or batch file.
     [exec] *******\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\src\main\resources\webapp\test\AutoTestWB\ui5-automation-framework\UI5Example>js
     [exec] Result: 1
[INFO] Executed tasks
[INFO] 
[INFO] --- maven-failsafe-plugin:2.12.2:verify (default) @ SampleWorkbench ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) @ SampleWorkbench ---
[INFO] Installing C:\Users\*******\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\target\SampleWorkbench.jar to C:\Users\*******\.m2\repository\SampleWorkbench\SampleWorkbench\1.0.0\SampleWorkbench-1.0.0.jar
[INFO] Installing C:\Users\*******\Desktop\BaseWB\SampleWorkbench\SampleWorkbench\pom.xml to C:\Users\*******\.m2\repository\SampleWorkbench\SampleWorkbench\1.0.0\SampleWorkbench-1.0.0.pom
[INFO] 
[INFO] --- maven-bundle-plugin:4.2.1:install (default-install) @ SampleWorkbench ---
[INFO] Installing SampleWorkbench/SampleWorkbench/1.0.0/SampleWorkbench-1.0.0.jar
[INFO] Writing OBR metadata
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:20 min
[INFO] Finished at: 2019-10-01T15:56:00+07:00
[INFO] ------------------------------------------------------------------------
Другие вопросы по тегам