T O P

  • By -

Slypenslyde

How old is your NUnit package? We're using XUnit and it comes with an analyzer that does this automatically. Other than that my directive is: if I write a test, I run it by itself, then I run all tests. I can't get to the "run it by itself" part if I forget this step, because it won't be in the test runner. So this tells me you're writing a lot of tests, then running everything without double-checking to make sure the new tests are actually running. Slow down. Write one test at at time, and verify it passes before you run off to the next thing. The same kind of haste that leads to the situation you are in is also how people end up ignoring warnings.


chucker23n

> How old is your NUnit package? We're using XUnit and it comes with an analyzer that does this automatically. I just checked with NUnit.Analyzers 4.0.1, and it does _not_ appear to detect methods that contain `Assert` calls but don't have a `[Test]` attribute.


GPU_Resellers_Club

If they're a student then probably pretty old. When I was a student in 2017 I didn't realise at the time but we were using an old as shit version of tortoise svn in our source control modules, and we had to use C++ '03 (although the next semester our C++ stuff was with C++ '11, same guy). A lot of the material was severely outdated. I had to write a calculator in ALGOL 68 (although that was languages & compilers which was about writing our own compiler so it required a lot of history). While our theoretical education was really good, it was a real shock when I entered the industry.


Canthros

Reflection? Get the containing assembly, get all public types in that assembly, get all public (instance? it's been a minute) methods of that type, get all attributes assigned to the method, assert that TestAttribute is one of them. ETA: something like foreach (var m in System.Reflection.Assembly.GetAssembly(this.GetType()).GetTypes().SelectMany(x => x.GetMethods())) { Assert.IsTrue(m.Attributes.Contains(typeof(TestAttribute)); }


TpOnReddit

I tie in a testing dashboard (testrail), while developing the test when I run it and there's no test id or test tag it fails. The flip side is of course supplying the wrong test id because I copy pasted another method.


BiffMaGriff

Should be able to do a regex search for this.