TheNexusAvenger / Nexus-Unit-Testing

Unit testing framework for Roblox.
MIT License
5 stars 3 forks source link

NexusUnitTesting.lua - where to find? #3

Closed psdillon closed 4 years ago

psdillon commented 4 years ago

The documentation at https://thenexusavenger.github.io/Nexus-Unit-Testing/getting-started/writing-tests/ instructs users to require a NexusUnitTesting module.

Does this mean that a NexusUnitTesting script needs to be downloaded and put in the Roblox Studio project somewhere? I could not find this file. Or am I meant to create an empty NexusUnitTesting module?

psdillon commented 4 years ago

I found that creating an empty ModuleScript made it work. It would be helpful if documentation mentioned this. Thanks.

TheNexusAvenger commented 4 years ago

The docs show 3 equivalent lines on how to require it. The recommended way is to use require("NexusUnitTesting") if you are using the Nexus Unit Testing runner or Nexus Unit Testing plugin. This makes it so you don't need to have it set up in your environment and it guarantees to get the version used by the runner.

psdillon commented 4 years ago

I used one of those lines and it did not work until I created an empty ModuleScript of the same name.

TheNexusAvenger commented 4 years ago

I will comment on this again when I have more context about how you are running it in the other issue (https://github.com/TheNexusAvenger/Nexus-Unit-Testing/issues/4). This sounds like a problem with your usage to me rather than the system itself, which would potentially call for a change in the docs.

TheNexusAvenger commented 4 years ago

Going back to this knowing that you are using the plugin, I am not sure what is going on in your case. I am able to get the test to correctly detect with just this:

local NexusUnitTesting = require("NexusUnitTesting")

return true

You can also make it detect by adding .spec or .nexusspec to the end of the script name, which will be required in the next release to make detection faster.

psdillon commented 4 years ago

I just tried your previous method and it worked. Previously I had stupidly used the line:

local NexusUnitTesting = require(game.ServerStorage.Tests.NexusUnitTesting)

With the assumption I would need to add a file at that path. The test script failed because it was an invalid path and not quoted.

Apologies, I'm new to Roblox Studio and Lua and should have realised the problem.

TheNexusAvenger commented 4 years ago

If you are new to Roblox Studio and already trying unit testing, I am really impressed. Glad to see it was a setup problem and not something on the plugin's end.