Using a small number of available user properties across a large number of threads



  • 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.



  • 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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2