Class rpycUnitTests
The following tests may seem a bit complicated, but since we need to
test with other processes, this takes time and thus we need to
implement waiting methods. We leverage the UnityTest attribute
for our waits. Contrary to regular C#, we can nest yield return
calls
and get the "intuitive" behaviour.
Inheritance
rpycUnitTests
Syntax
public class rpycUnitTests
Properties
Declaration
public static bool ClientContactFlag { get; set; }
Property Value
Methods
AsyncClientToServerCall()
Note: nUnit should support asynchronous tests, but since unity is on a custom version
there is something that prevents it from playing nice. "Await" manually on it
Declaration
public IEnumerator AsyncClientToServerCall()
Returns
CallServiceWithoutClient()
Calls a service but there's no client.
Verify it makes a reasonable error.
Declaration
public void CallServiceWithoutClient()
CoroutineClientToServerCall()
Tests that we can:
- spawn a client
- call a service on it asynchronously and have it play well with a coroutine
- have the client call into Unity to manipulate the scene (create and rename an object)
Declaration
public IEnumerator CoroutineClientToServerCall()
Returns
RestartServer(String)
Stops the server, then restart it, and wait for client to reconnect.
Declaration
public IEnumerator RestartServer(string clientID = "")
Parameters
Type |
Name |
Description |
String |
clientID |
Client ID used to see if the reconnected
client is the one we expect. Only used if the shouldReconnect
parameter is true
|
Returns
SetUp()
Declaration
StartAndStopServer()
Tests that we can:
- spawn a client
- call a service on it and get a result
- shut down the server inviting a reconnect
- reopen the server
- find the same client and have it return proof that it knows the server shut down
Declaration
public IEnumerator StartAndStopServer()
Returns
StartClient(String, String)
Starts a client (and the server if needed). Use as an IEnumerable or a coroutine
Declaration
public IEnumerator StartClient(string clientID, string clientName = "com.unity.scripting.python.tests.rpyc")
Parameters
Type |
Name |
Description |
String |
clientID |
Client's second name. Specified by the caller
|
String |
clientName |
|
Returns
TearDown()
Declaration
TestBaseClient()
Declaration
public IEnumerator TestBaseClient()
Returns
TestClientWithoutServices()
Declaration
public IEnumerator TestClientWithoutServices()
Returns
TestKillClient()
Declaration
public IEnumerator TestKillClient()
Returns
TestNewerClient()
Declaration
public IEnumerator TestNewerClient()
Returns
TestServedExposedFunctions()
Declaration
public IEnumerator TestServedExposedFunctions()
Returns
UT1449StopServerWhileClientIsBusy()
Declaration
public IEnumerator UT1449StopServerWhileClientIsBusy()
Returns
WaitForSecondsDuringUnityTest(Double, Func<Boolean>)
Because UnityTests can only yield return null (or an IEnumerator
yield returning null), we cannot use Unity's WaitForSeconds. Make
our own version.
If a condition function was given, if the condition never evaluated
to True during the loop, raises a Assert.Fail
Declaration
public IEnumerator WaitForSecondsDuringUnityTest(double waitTime, Func<bool> condition = null)
Parameters
Type |
Name |
Description |
Double |
waitTime |
The interval of time to wait for, in seconds.
|
Func<Boolean> |
condition |
A function returning a boolean. If the function returns true, exit early.
|
Returns
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.