If you feel that creating and compiling a C# load test project is to much overhead, you can now also run a pure .cs file directly as a load test script.
If you're not comfortable with how to write a load test with GrinderScript.Net, we recommend that you (re)visit the description of how to write load test before you continue.
You need the GrinderScript.Net.CsScript NuGet package installed to use this feature. If you've already installed the GrinderScript.Net.Samples package, you also have GrinderScript.Net.CsScript installed, otherwise you install it from the Visual Studio Package Manager Console with the command
or by running NuGet.exe from the command line, e.g.:
C:\Util\NuGet.exe install GrinderScript.Net.CsScript -OutputDirectory C:\MySolution\ExternalLibs
Internally GrinderScript.Net use the excellent C# script engine Cs-Script's hosting functionality to do all the hard work of dynamically loading and compiling your .cs file into code in the CLR. We uses the new CS-Script Evaluator, that is based on Mono's compiler as service. You can use all the CS-Script features that are supported in hosted evaluator mode, with one limitation: Your .cs script file must contain a class that implements the GrinderScript.Net.Core.IGrinderWorker interface. Duck typing or scripts containing only a method definition is currently not supported. Please consult the CS-Script Documentation if you want to learn more about CS-Script's features. The good news is that you can implement your worker using any of the strategies described in the Writing load tests page.
Beside writing your worker in the .cs script file, all you need to configure your grinder.properties following these three steps:
Here is the interesting parts taken from the grinder.properties in the GrinderScript.Net.Samples CsScript example:
grinder.script=..\\..\\..\\GrinderScript.Net.CsScript.dll grinderscript-dotnet.workerType=GrinderScript.Net.CsScript.CsScriptWorker, GrinderScript.Net.CsScript grinderscript-dotnet.csScriptWorker.script=.\\Samples\\GrinderScript.Net\\Core\\WorkerThatLogs.cs
With this in place you can use a workflow where you write some load test script in a .cs file, save the file and then run it directly from the Grinder Console, in an iterative process. The Grinder Console will automatically distribute the changed script file to all your Grinder Agents.