assertions

xpath assertion failure with dynamic xpath

谁都会走 提交于 2019-12-08 07:51:31
问题 This is very similar to: adding php variable into Xpath But slightly different... What I'm trying to do is this: $status = "Test!"; //ajax request to update the page $this->postToPage($status); //This is the part that is failing.. $this->waitUntil(function () { if ($this->byXPath("//span[contains(text(),'{$status}')]")) { return true; } return null; }, 20000); $elementtext = $this->byXpath("//span[contains(text(),'{$status}')]")->text(); $this->assertEquals($status, $elementtext); Failed

mysql triggers simulating assertions

若如初见. 提交于 2019-12-08 04:51:11
问题 Let’s consider table Video( IDvideo(PK), Date, Description, User ) with mysql I have no way of writing assertions. Is it possible to simulate the following assertion using one or more triggers ? create assertion asser1 check (0 = ( select count(*) from Video where Date >= DATE_SUB(current_date(),INTERVAL 1 YEAR ) && Date<=current_date() group by User having count(*) > 200 ) ) how should I write that trigger? 回答1: Well, the problem is that MySQL doesn't have an equivalent of a STOP ACTION

xpath assertion failure with dynamic xpath

不想你离开。 提交于 2019-12-08 03:20:29
This is very similar to: adding php variable into Xpath But slightly different... What I'm trying to do is this: $status = "Test!"; //ajax request to update the page $this->postToPage($status); //This is the part that is failing.. $this->waitUntil(function () { if ($this->byXPath("//span[contains(text(),'{$status}')]")) { return true; } return null; }, 20000); $elementtext = $this->byXpath("//span[contains(text(),'{$status}')]")->text(); $this->assertEquals($status, $elementtext); Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'Test!' +'Test!.' Any idea why

Smalltalk and Assertions

孤人 提交于 2019-12-07 22:53:18
问题 Tryng out some smalltalk + TDD + "good practices" I've run into a kinda ugly block: How do I do an assertion in GNU Smalltalk? I'm just looking for a simple ifFalse: [Die] kind of thing 回答1: This is the code for assert: from Squeak (which I recommend you use rather than GNU): assert: aBlock "Throw an assertion error if aBlock does not evaluates to true." aBlock value ifFalse: [AssertionFailure signal: 'Assertion failed'] 回答2: as well as self assert: [ ... some block ] works for blocks & non

Why does my Haskell assertion only happen in IHaskell?

白昼怎懂夜的黑 提交于 2019-12-07 11:12:44
问题 If I define import Control.Exception (assert) import Data.Char (ord) f :: String -> String f s = assert (all (`elem` letters) s) $ (letters!!) <$> (ix <$> s) where ix ch = (ord ch - ord 'A') letters = ['A'..'Z'] then if I execute f "AB.CD" in IHaskell, I get :10:7-12: Assertion failed as I would expect. But in all other settings, the assertion seems to be ignored. For example in GHCi (7.10.2) I get ghci>f "AB.CD" "AB*** Exception: Prelude.!!: negative index and if I put the expression in a

Is there a way how to continue after Debug.Assert() from the code?

蹲街弑〆低调 提交于 2019-12-07 09:53:39
问题 My code operates on data which "should" be correct. However during development there are occasions when I obtain invalid data. When that happens I would like to raise the debug assert and, if user choose to continue, the code would filter out the invalid records and continue to operate on "safe" data. // assert incorrect data Debug.Assert(person.Items.All(item => item.IsValid), "Inconsistent data!"); // operate on filtered data this.ItemViewModels = new ObservableCollection<ItemViewModel>(

Assert arrays in Protractor

夙愿已清 提交于 2019-12-07 06:58:06
问题 I am working on E2E tests and my goal is to compare two arrays. I set these arrays so that they are identical. The problem is that Protractor doesn't think they are same. My code: expect(arrPuv).toBe(arrNov); Console output: Error: Expected [ '1 patro', '2. Patro', 'asdf', 'My precious', 'My precious', 'My precious', 'My precious' ] to be [ '1 patro', '2. Patro', 'asdf', 'My precious', 'My precious', 'My precious', 'My precious' ]. How can I compare them correctly? 回答1: This actually goes

c# - Asserting with OR condition

青春壹個敷衍的年華 提交于 2019-12-07 03:13:01
问题 i am checking a string for three characters Assert.AreEqual(myString.Substring(3,3), "DEF", "Failed as DEF was not observed"); the thing is here it can be DEF or RES , now to handle this what i can think of is the following bool check = false; if( myString.Substring(3,3) == "DEF" || myString.Substring(3,3) == "RED" ) check = true; Assert.IsTrue(check,"Failed"); Console.WriteLine(""Passed); IS THERE a way i can use some OR thing within Assert p.s i'm writing unit test & yes i will use ternary

Assertion fail message for string contains substring [duplicate]

安稳与你 提交于 2019-12-06 05:55:48
This question already has answers here : AssertContains on strings in jUnit (7 answers) Closed 6 years ago . I have done a lot of functional testing on text outputs on text generating software lately, an find myself writing a lot of assertTrue(actualString.contains(wantedString)); However, the message for when this fails is something non-descriptive like Expected [true], but was [false] An alternative is to include a custom fail message as String failMsg = String.format("Wanted string to contain: %s, Actual string: %s", wantedString, actualString); assertTrue(failMsg, actualString.contains

Cobertura coverage and the assert keyword

别说谁变了你拦得住时间么 提交于 2019-12-06 01:57:36
问题 My line coverage for unit tests measured by Cobertura is suffering, because I have assert statements which are not covered in tests. Should I be testing assert ions, and is there any way to get Cobertura to ignore them so they do not affect my test coverage? 回答1: The line coverage of your Java assert statements should be simply covered by running your test suite with assertions enabled, i.e., giving -ea as argument to the jvm. If you do this, you'll see that cobertura easily reports 100% line