2012-02-03 61 views
3

我已經在本地Windows機器和遠程Linux服務器上安裝了PHPUnit。我能夠從Netbeans本地運行PHPUnit。我的下一步是,使用NetBeans觸發PHPUnit.bat腳本: - SSH遠程服務器 - 運行PHPUnit的從那裏PHP在Netbeans + PHPUnit遠程服務器上進行單元測試,可能嗎?

手動,我可以用砰砰到SSH和取回從遠程服務器的PHPUnit的輸出跑。

關於如何配置PHPUnit.bat腳本來做到這一點的任何想法?

回答

0

您需要編寫自己的批處理腳本來執行相同的手動步驟。捕獲NetBeans傳遞的參數,ssh到服務器,並使用相同的參數執行PHPUnit應該不會太困難。

由於這不是PHPUnit所特有的,爲了獲得更廣泛的支持,您應該重新發布此問題以將腳本編寫者作爲目標。

+0

我會盡力,感謝您的建議。 – fred 2012-02-05 05:23:51

+0

@fred你可以添加一個鏈接到示例批處理腳本? – corretge 2012-07-31 09:13:11

3

如果這可以幫助:從NetBeans的7.4遠程運行PHPUnit的Windows腳本:

phpunit.bat

@echo off 
:: ============================================================= 
:: Remote execute phpunit command to VM and downloading result 
:: ============================================================= 
:: - assuming project is replicated remotely (WinSCP ?) 
:: - assuming NetBeansSuite.php file somewhere in remote VM 
:: - using 
::  * PuTTY tools - http://www.chiark.greenend.org.uk/~sgtatham/putty/ 
::  * sed.exe - http://gnuwin32.sourceforge.net/packages/sed.htm 

:: remote serveur PuTTY silent connection (auto-login, key authentication with pageant) 
set REMOTE_SERVER=your_putty_saved_session_name 
:: root path of all local netbeans projects, despecialized for sed 
set LOCAL_WORKSPACE=C:\/Apps\/Wamp\/www 
:: remote path of all projects, despecialized for sed 
set REMOTE_WORKSPACE=\/var\/www\/projects 
:: remote location of NetBeansSuite.php, despecialized for sed 
set REMOTE_NETBEANSSUITE=\/usr\/local\/share\/php\/phpunit\/NetBeansSuite.php 

:: Location of junit log 
set REMOTE_LOG_JUNIT=nb-phpunit-log.xml 
:: Patch params : \ to /, clean log path, change workspace, change NetBeansSuite 
echo %* | sed -e "s/\\/\//g" -e "s/[^ ]*nb-phpunit-log.xml/%REMOTE_LOG_JUNIT%/g" -e "s/%LOCAL_WORKSPACE%/%REMOTE_WORKSPACE%/g" -e "s/[^ ]*NetBeansSuite.php/%REMOTE_NETBEANSSUITE%/g" > %TMP%\res.txt 
set /p PARAMS=<%TMP%\res.txt 

:: Launch phpunit and revert remote path in the output 
echo plink -batch %REMOTE_SERVER% "phpunit %PARAMS% | sed -e 's/%REMOTE_WORKSPACE%/%LOCAL_WORKSPACE%/g' -e 's/\//\\/g'" 
plink -batch %REMOTE_SERVER% "phpunit %PARAMS% | sed -e 's/%REMOTE_WORKSPACE%/%LOCAL_WORKSPACE%/g' -e 's/\//\\/g'" 

:: Download result 
set LOCAL_LOG_JUNIT=%3% 
pscp -q -batch %REMOTE_SERVER%:%REMOTE_LOG_JUNIT% %TMP%\res.txt 

:: Revert remote path to local path in log file (beware of XML ending tag which must not be translated). 
sed -e "s/%REMOTE_WORKSPACE%/%LOCAL_WORKSPACE%/g" -e "s/\([^<]\)\//\1\\/g" %TMP%\res.txt > %LOCAL_LOG_JUNIT% 
相關問題