2016-08-19 7 views
0
私が午前

たPowerShellスクリプトをロードする方法私の.ps1一般に実行中に別のディレクトリにテストケース

enter image description here

は、我々が使用するのと同じフォルダ内にdirectory2directory1とMT .tests.ps1に保存されています次のようにテストファイルとスクリプトファイルが同じフォルダ内にあるとき

$here = Split-Path -Parent $MyInvocation.MyCommand.Path 
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' 
. "$here\$sut" 

スクリプトを書くしかし、私はそう、別のフォルダにそれらを持っていますスクリプトファイルが

答えて

0

をロードされる必要があるように、次のように私は正常に動作どのコード化したパスを読み込むことができますどのように

$project = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace(".Tests", "") 
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".tests.", ".") 
. "$project\$sut" 
関連する問題