0

I have a test suite with a big amount of tests. I would like those tests to run simultaneously by sending them to my HUB(assuming I have 2 Nodes). meaning, run all of my tests(locally or in Teamcity) and I'm expecting the result to be that Node1 will run test#1 while ,at the same time, Node2 will run test#2. in fact, what's happening at the moment is that test#1 will run on Node1 and when it finishes, and just then, test#2 will be executed on Node2 and so on...

I can split my tests into two projects or open two sessions of Visual Studio and run them simultaneously, and the HUB will do the rest(right?) , but it sounds like a bad approach.

My code is written in C#.

JumpIntoTheWater
  • 1,306
  • 2
  • 19
  • 46
  • Huge task , but not impossible – Saurabh Verma Jan 10 '18 at 11:21
  • the hub is working as expected, just remember that you executing test framework has to work in parallel – Henning Luther Jan 10 '18 at 12:05
  • @HenningLuther what does it mean that my executing test framework has to work in parallel? I'm working with Nunit – JumpIntoTheWater Jan 10 '18 at 12:06
  • you execute your tests with a framework, right? in java we normally use testng where it runs in parallel. for me it seems, that your execution is single threaded – Henning Luther Jan 10 '18 at 12:10
  • Yes, I'm using Nunit. So I need to search for how to run in multi thread? as far as I understand the answer is yes, my executes are in single thread. – JumpIntoTheWater Jan 10 '18 at 12:18
  • yes, exactly... – Henning Luther Jan 10 '18 at 13:02
  • This should not be a huge task. I agree with above, just look at how to execute tests in parallel with NUnit. However, you need to also make sure that your tests don't edit shared data or you'll get inconsistent results when the test data for one test steps on another's toes. – mrfreester Jan 10 '18 at 18:26
  • 10x all. my biggest problem at the moment is to figure out how to do that in parallel, although it's bee said several times here it's not a big issue. Any link or guide will be much appreciated. – JumpIntoTheWater Jan 12 '18 at 16:24

2 Answers2

0

Rather than use a build that to run the test, e.g. task 1: node test test1, task 2 nude test test2.

Have a task that spawns 2 subshell and wait for both to finish. e,g, task 1: bash test1() node test1 & test2() node test2 &

the () means to run it in a sub shell, so that wll spawn a new thread for you, and the & means to run in background so that it will run both at the same time. Then you will need to somehow wait for both to end, either by doing a while -z ps-aux grep test1 (while there is a process of of regex test1)

If you want to run it on a seperate pc, then you can scp the file across to the other pc, and ssh to start the test, and then do while loop to wait for a finish.txt file.

0

Since your code written in C# I assume you use NUnit and NUnit runner can run tests simultaneously since NUnit3 release, so all you need is to add

[assembly: Parallelizable(ParallelScope.Fixtures)]

to your properties AssemblyInfo.cs file. It worked for me.

v_vitalik
  • 11
  • 3