vocksel / code-cop Goto Github PK
View Code? Open in Web Editor NEWUnit testing plugin for Roblox Studio
Unit testing plugin for Roblox Studio
As detailed in the Caveats section of the README, support for a team environment is currently very poor. We need a better system for importing modules that will not interfere with other users.
One proposed by einstienK on the devforums looks incredibly promising and should be exactly what we need:
local function assertf(c,m,...)
if c then return end
error(m:format(...),0)
end
local loading,ERR = {},{}
local function customRequire(mod)
local cached = loading[mod]
while cached == false do wait() cached = loading[mod] end
assertf(cached ~= ERR,"Error while loading module")
if cached then return cached end
local s,e = loadstring(mod.Source)
assertf(s,"Parsing error for %s: %s", mod:GetFullName(), tostring(e))
loading[mod] = false
local env = setmetatable({
script = mod;
require = customRequire;
},{__index=getfenv()})
s,e = pcall(setfenv(s,env))
if not s then loading[mod] = ERR end
assertf(s,"Running error for %s: %s", mod:GetFullName(), tostring(e))
loading[mod] = e return e
end
customRequire(firstModule)
It's just a matter of implementing this now. I have other projects to worry about right now but this is a top priority when I get back to working on Code Cop. (If anyone else stumbles upon this and wants to give it a shot tho, feel free)
Once implemented we can also delete the Caveats section as it only applies to this issue.
Nice plugin! However, sometimes it is useful to write a test that we expect to fail (e.g., verify that certain inputs yield an error). I tried to wrap the invocation of my uut in a pcall, and assert that it returns false, but it looks like the pcall in the plugins TestCase script still interprets the call as a failure.
I was going to modify my local plugin to allow the passing of a flag to indicate an expected failure, and to invert the built-in assertion following the pcall to the callback, but wanted to post an issue first, in case there is already a built-in and recommended way of doing this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.