Support
Quality
Security
License
Reuse
Coming Soon for all Libraries!
Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
Entitas - The Entity Component System Framework for C# and Unity
public static GameEntity CreateRedGem(this GameContext context, Vector3 position) {
var entity = context.CreateEntity();
entity.isGameBoardElement = true;
entity.isMovable = true;
entity.AddPosition(position);
entity.AddAsset("RedGem");
entity.isInteractive = true;
return entity;
}
QUESTION
Unit tests are inconclusive when adding xUnit project to Unity project
Asked 2020-Nov-10 at 07:33I create a new Unity project and make sure the Assembly-CSharp.csproj
file exists by creating a script in the Assets folder. I open that script and edit it to
public class AScript : MonoBehaviour {}
I close the IDE and Unity after that. The Assembly-CSharp.csproj
file exists now in the root directory of the project.
I start my IDE again (without Unity) and open the project from the .sln file. I add a new xUnit project to the solution and modify the first test to
[Fact]
public void Test1()
{
Assert.True(true);
}
Just for the sake of completeness I reference the Unity project in my test project. When running the test (which should be fine) the tests didn't run because they are inconclusive. I found this information in the test output
Last runner error: No such file or directory
Below I will post the whole test output. Does someone know how to add a unit test project to a Unity project? Please let me know if you need more information.
I don't want to use the Unity test framework because I'm using Entitas and don't want to rely on the engine. I just want to test my pure C# code outside.
I'm also curious why Rider comes up with this when adding the test project to the solution
I got it working but I don't like the solution, so please explain if this is the only way or if this is wrong (as I think)
When creating a completely new solution with only that test project the unit tests will run correctly. Now I can add the existing Unity project via "Add existing project". Referencing the Unity project works fine too.
So yeah this works but now I have two solutions in my repository? Why do I have to separate the test project? Why can't I just add the unit test project to Unity's solution file?
This is the whole test output
TestProject1.UnitTest1.Test1
Test not run
Last runner error: No such file or directory
--- EXCEPTION #1/2 [Win32Exception] Message = “No such file or directory” ExceptionPath = Root.InnerException ClassName = System.ComponentModel.Win32Exception HResult = E_FAIL=EFail=80004005 Source = System.Diagnostics.Process NativeErrorCode = 2 StackTraceString = “ at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at JetBrains.ReSharper.UnitTestFramework.Processes.PreparedProcess.Start() at JetBrains.ReSharper.UnitTestFramework.TestRunner.TestRunnerRunStrategy.<>c.b__19_1(IPreparedProcess p) at JetBrains.Util.Special.GeneralUtil.With[T](T control, Action
1 action) at JetBrains.ReSharper.UnitTestFramework.TestRunner.TestRunnerRunStrategy.StartTestRunner(IUnitTestRun run, ITestRunnerEnvironmentSpecifier environmentSpecifier, IUnitTestAgentCommunicationChannel channel) at JetBrains.ReSharper.UnitTestFramework.TestRunner.TestRunnerRunStrategy.Run(IUnitTestRun run) --- End of stack trace from previous location where exception was thrown --- at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestRun.StartCore(CancellationToken onCancel, CancellationToken onAbort) at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestRun.<>c.<StartCore>b__29_0(ExceptionDispatchInfo e) at JetBrains.Util.Special.GeneralUtil.WithNotNull[T](T item, Action
1 F) at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestRun.StartCore(CancellationToken onCancel, CancellationToken onAbort) at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestRun.Start(CancellationToken onCancel, CancellationToken onAbort) ”--- Outer ---
--- EXCEPTION #2/2 [LoggerException] Message = “No such file or directory” ExceptionPath = Root ClassName = JetBrains.Util.LoggerException InnerException = “Exception #1 at Root.InnerException” HResult = COR_E_APPLICATION=80131600 StackTraceString = “ at JetBrains.Util.ILoggerEx.LogException(ILogger this, LoggingLevel level, Exception exception, ExceptionOrigin exceptionOrigin, String comment) at JetBrains.Util.ILoggerEx.Error(ILogger this, Exception exception, ExceptionOrigin origin, String comment) at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestRun.Start(CancellationToken onCancel, CancellationToken onAbort) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at JetBrains.ReSharper.UnitTestFramework.Launch.UnitTestRun.Start(CancellationToken onCancel, CancellationToken onAbort) at JetBrains.ReSharper.UnitTestFramework.Launch.Stages.RunTestsStage.<>c__DisplayClass5_0.b__0() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) at System.Threading.Tasks.Task.ExecuteFromThreadPool(Thread threadPoolThread) at System.Threading.ThreadPoolWorkQueue.Dispatch() ”
ANSWER
Answered 2020-Nov-10 at 07:33Unfortunately you can't manipulate the csproj or sln files because Unity will throw them away after next compilation.
Just create new solution with a test project right next to the Unity project. Add the Unity project as an existing project to your test solution.
Since you mentioned you are using Entitas you can follow this guide to setup your tests
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit