0

I'm currently building a testing framework for functional tests. I can run them in parallel using Cucumber but I have run into a problem in creating users for each thread (each test requires a brand new user).

I have a user.properties file with details for each new user created. Duplication doesn't matter for most fields and my emails are different each time because I use something like this "useremail" + System.currentTimeMillis + "@example.com".

My problem arises when reusing phone numbers. It needs to be a valid phone number and cannot be duplicated across accounts. I tear down users with the phone number at the beginning of each test. But running over multiple threads causes clashes of numbers.

I have 2 stored numbers in my user.properties which I hope to cycle through using a synchronized method for each thread and lock that number to that thread. But I aim to have more than 2 threads (as many phones that I can attach to be honest).

Every solution I come up with feels hacky and I'm quite new to this. Does anyone know of a good solution to distribute a finite number of user properties across multiple threads so they don't clash?

Thought of using the actual device or emulator's number (not sure if appium can extract that), but even if I could, my numbers need to be UK numbers

Thanks for your help.

0

Why don't you generate the phone number in a similar way you do with the email? I am pretty sure you could use unix timestamp and just get the last n numbers you need for a phone number to be valid.

  • I tear down my numbers at the start of each test, prefer to start with a blank slate. If I created a brand new number, I wouldn't be able to tear that down, as it would be created as the test starts. – JordiLaForge Apr 30 at 12:34
  • Why not clean up after the test run? – Moro Apr 30 at 12:40
  • Honestly, I can't think of a reason right now. My suite originally had that, but over and over again I saw advice to perform cleanup of your environment before a test run so I changed it. Like I said, that's not a red line for me, I'll change if neccessary, but jsut want to see what advice there is out there – JordiLaForge Apr 30 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.