|
There are several rants on the functionality of mstest... Yes, it offers a little less than other unit test frameworks.
But there are geniuses using it. What about:
Assert.AreEqual(actual, expected, "Value is wrong: {0}, expected: {1}.", actual, expected); That guy always wrote a custom message showing both the actual and the expected value. Has he ever read the message of a failing test?
Let's try with int expected = 42; int actual = 7; . The message is:
Assert.AreEqual failed. Expected:<7>. Actual:<42>. Value is wrong: 7, expected: 42. See: another bug.
Strangely, intellisense shows the signature correctly:
Assert.AreEqual<int>(int expected, int actual, string message, params object[] parameters) (+17 overloads) Well, even mstest is better than some professionals.
[Edit]
Strange that I need to explain further...
The mstest framework works here absolutely the way it is documented, without any bugs.
A potential source of confusion is the order of arguments to Assert.AreEqual - NUnit does it the other way round. But intellisense shows it correctly, so anyone looking at the screen when writing the test will see where "actual" and "expected" have to go.
For testing your tests, you are expected to show that your test can fail, aren't you? At that moment, you will see the failure message. And now you have another opportunity to see where actual and expected should go: even when you do not provide a custom message mstest will tell you "Assert.AreEqual failed. Expected:<7>. Actual:<42>.", if you provide a custom message that will be appended. And thus you'll see that you do not need to repeat actual and expected in your custom message.
What happened to CodeProject that I need to say that so explicitly?
[/Edit]
modified 23-Feb-17 3:05am.
|
|
|
|
|
It's what I like to call the Microsoft 85% Principle. Pretty much all of their products are worked upon until they're approximately 85% complete and working. After that, functionality it either left missing or broken.
Ah, I see you have the machine that goes ping. This is my favorite. You see we lease it back from the company we sold it to and that way it comes under the monthly current budget and not the capital account.
modified 31-Aug-21 21:01pm.
|
|
|
|
|
What about people testing the framework?
Assert.AreEqual(int.Parse("42"), 42); If that piece of code starts to fail you've got bigger problems than a failing unit test
Just stick to testing your own code (and maybe some external code you expect to change)
|
|
|
|
|
Worse is (and I'm not sure about NUnit) here, that .AreEqual uses obj.Equals for comparison by default. It has overloads for common value types, but in some cases can yield surprises.
Generally, I think many test frameworks suffer from featuritis. It is better to simply have an Assert() method, taking a single Boolean expression, than have the possibility of bugs or unexpected behaviour in the test framework.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Once upon a time, the concept of enumeration had not yet been invented. Instead, you had to use long lists of const definitions mapping some name to some int. So I found a colleague writing code like:
private int DecodeElementType(string elementName)
{
switch (elementName)
{
case "Blah": return 1;
case "Blub": return 2;
case "Hmpf": return 3;
case "Grml": return 4;
case "Tralala": return 5;
default: return 0;
}
} I asked him if he knew what an enum is, and how to use Enum.Parse / Enum.TryParse. He said he knew that. But his code is superior...
|
|
|
|
|
Sooooo, when I pass in TRalala to his code, it's still going to be superior.
This space for rent
|
|
|
|
|
You're going to get 0, unless you mean "Tralala".
|
|
|
|
|
|
Please use some other display method. As an engineer, I am "expression-blind"
(see Engineers are cold and dead inside)
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Sudden Sun Death Syndrome (SSDS) is a very real concern which we should be raising awareness of. 156 billion suns die every year before they're just 1 billion years old.
While the military are doing their part, it simply isn't enough to make the amount of nukes needed to save those poor stars. - TWI2T3D (Reddit)
|
|
|
|
|
Bernhard Hiller wrote: He said he knew that.
If I were a betting man (and I am), I would wager my house that he did not know that.
Slogans aren't solutions.
|
|
|
|
|
Implicit enums are ever worse.
public enum Implicit
AA_0
BB_1
CC_2
DD_3
EE_4
GG_6
HH_22
II_7
LL_17
...
end enum
Guess what value did HH_22 have? And GG_6? BTW the numbers in the end are useful since this enum maps fixed alarm codes that come from a PLC. The only reason the code worked was because the same creator of this enum didn't use its values but used magic numbers all over the code.
Half a day hunting for a bug because alarm 31 never matched with '== XX_31'. XX_31 equalled 30.
* CALL APOGEE, SAY AARDWOLF
* GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
* Never pay more than 20 bucks for a computer game.
* I'm a puny punmaker.
|
|
|
|
|
Sounds like a case of the wrong tool for the job. Implicit enums are great for representing a fixed set of ideas/behavior (like flags) that isn't mapped to specific values. If you need a fixed set mapped to specific values use explicit enums
|
|
|
|
|
Precisely. Even if I'm used to always explicit the enums - mainly because I work with a system that has a lot of marshalling and communications between different paradigms so more often than not I end up having to fix those values sooner or later.
* CALL APOGEE, SAY AARDWOLF
* GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
* Never pay more than 20 bucks for a computer game.
* I'm a puny punmaker.
|
|
|
|
|
My guess, he didn't know. Self-tough programming. What so superior about coding manually. The point of using enumeration is to allow the compiler to check for potential human errors. Tell him to go back to school.
|
|
|
|
|
I'd guess he did learn to code in school. Meaning he had coding courses, learned nothing (as usual, because those courses invariable suck), and then assumed he would not need learn any further.
|
|
|
|
|
Whats the language that can use a string in a switch statement?
|
|
|
|
|
I think the snippet is in C#, which does allow that.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
OK, makes sense. C++ allows for a lot of this kind of thing through operator overloading, though I tend to be a pure C programmer, and I like the level of clunky direct control you have of the code with C.
|
|
|
|
|
Just read the user manual that came with the WookieTab, and thought I'd share.
Are you sitting comfortably? OK, lets begin!
Dear users, Thank you for your purchase of CHUWI products Hi12Series Tablet poly nuclear, Hi12 is a quad-core Tablet PC products CHUWI well - launch of the brand can swim the internet.
This poly-core series Tablet PC can' t suffer drip and splash water, and can' t place it beside such as full glass of Liquid body.
Ah...bliss. Reminds me of the early Japanese motorcycle manuals, where someone at Suzuki had difficulty with the "f" in "shifting" - leading to a whole chapter talking about "if you have difficulty in shiting ..."
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
OriginalGriff wrote: if you have difficulty in shiting ...
... then take a Chuwi tablet three times a day.
OriginalGriff wrote: full glass of Liquid body
Yum, soylent green!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Old Italian IBM manuals are still renowned for their translations of "mouse balls" which was quite literally "mouse b*ll*cks".
* CALL APOGEE, SAY AARDWOLF
* GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
* Never pay more than 20 bucks for a computer game.
* I'm a puny punmaker.
|
|
|
|
|
Are you sure they didn't want to mean "liquid nitrogen"?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I used to love reading the user manuals that came with oriental products in the 1960s. I wish i still had some of them.
We're philosophical about power outages here. A.C. come, A.C. go.
|
|
|
|
|
The fun has not ended yet. Take at look at the Top 10 Best Photography Lighting Sets In 2017 Reviews, and you will find this for the Neewer 600W kit:
"With some magnificent features and productivity, this lighting set furnishes its users with the most extreme nature of lighting. There are a couple of positive conditions that are given moreover offered by this pack. This master pack can be a perfect ruffle for advancing any things, cutting edge, photo workmanship, moreover particular photography.
This set is open at to a great degree mind boggling and sensible cost. Everything is created use premium things, so they can continue going for a long time. There are a couple of profitable things that are open in this kit, for instance, streak lights, umbrellas, fragile boxes, light stands, creature abode passages, and whatever different well-known things.
Among the numerous expert studio photography lighting kits, the Studio Pro has set some unsurpassable elevated requirements that made it a standout amongst the most well-known available today. Including magnificent features and capacities with regards to ideal outcomes, this pack deals with each picture taker’s need."
|
|
|
|