Search Results

Search found 10206 results on 409 pages for 'tooling and testing'.

Page 98/409 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • UnitTest ExpectedException with multiple Exceptions

    - by masterchris_99
    I want one TestMethod for multiple exceptions. The Problem ist that the Testmethod stops after the first thrown exception. I know that I can do something like that: try { sAbc.ToInteger(); Assert.Fail(); // If it gets to this line, no exception was thrown } catch (ArgumentException) { } But I want to use the following code-base: [TestMethod, ExpectedException(typeof(ArgumentException), "...")] public void StringToIntException() { sAbc.ToInteger(); // throws an exception and stops here sDecimal.ToInteger(); // throws theoretically a exception too... } And I don't want to create one testmethod for each possible exception like that: [TestMethod, ExpectedException(typeof(ArgumentException), "...")] public void StringToIntException() { sAbc.ToInteger(); } [TestMethod, ExpectedException(typeof(ArgumentException), "...")] public void StringToIntException() { sDecimal.ToInteger(); }

    Read the article

  • Weird .net 4.0 exception when running unit tests

    - by vdh_ant
    Hi guys I am receiving the following exception when trying to run my unit tests using .net 4.0 under VS2010 with moq 3.1. Attempt by security transparent method 'SPPD.Backend.DataAccess.Test.Specs_for_Core.When_using_base.Can_create_mapper()' to access security critical method 'Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(System.Object)' failed. Assembly 'SPPD.Backend.DataAccess.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception. The test I am running is really straight forward and looks something like the following: [TestMethod] public void Can_create_mapper() { this.SetupTest(); var mockMapper = new Moq.Mock<IMapper>().Object; this._Resolver.Setup(x => x.Resolve<IMapper>()).Returns(mockMapper).Verifiable(); var testBaseDa = new TestBaseDa(); var result = testBaseDa.TestCreateMapper<IMapper>(); Assert.IsNotNull(result); //<<< THROWS EXCEPTION HERE Assert.AreSame(mockMapper, result); this._Resolver.Verify(); } I have no idea what this means and I have been looking around and have found very little on the topic. The closest reference I have found is this http://dotnetzip.codeplex.com/Thread/View.aspx?ThreadId=80274 but its not very clear on what they did to fix it... Anyone got any ideas?

    Read the article

  • Difficulty thinking of properties for FsCheck

    - by Benjol
    I've managed to get xUnit working on my little sample assembly. Now I want to see if I can grok FsCheck too. My problem is that I'm stumped when it comes to defining test properties for my functions. Maybe I've just not got a good sample set of functions, but what would be good test properties for these functions, for example? //transforms [1;2;3;4] into [(1,2);(3,4)] pairs : 'a list -> ('a * 'a) list //' //splits list into list of lists when predicate returns // true for adjacent elements splitOn : ('a -> 'a -> bool) -> 'a list -> 'a list list //returns true if snd is bigger sndBigger : ('a * 'a) -> bool (requires comparison)

    Read the article

  • MSTest unit test passes by itself, fails when other tests are run

    - by Sarah Vessels
    I'm having trouble with some MSTest unit tests that pass when I run them individually but fail when I run the entire unit test class. The tests test some code that SLaks helped me with earlier, and he warned me what I was doing wasn't thread-safe. However, now my code is more complicated and I don't know how to go about making it thread-safe. Here's what I have: public static class DLLConfig { private static string _domain; public static string Domain { get { return _domain = AlwaysReadFromFile ? readCredentialFromFile(DOMAIN_TAG) : _domain ?? readCredentialFromFile(DOMAIN_TAG); } } } And my test is simple: string expected = "the value I know exists in the file"; string actual = DLLConfig.Domain; Assert.AreEqual(expected, actual); When I run this test by itself, it passes. When I run it alongside all the other tests in the test class (which perform similar checks on different properties), actual is null and the test fails. I note this is not a problem with a property whose type is a custom Enum type; maybe I'm having this problem with the Domain property because it is a string? Or maybe it's a multi-threaded issue with how MSTest works?

    Read the article

  • Spec. for JUnit XML Output

    - by Gilad Naor
    Where can I find the specification of JUnit's XML output. My goal is to write a UnitTest++ XML reporter which produced JUnit like output. See: "Unable to get hudson to parse JUnit test output XML" and "http://stackoverflow.com/questions/411218/hudson-c-and-unittest"

    Read the article

  • Proper way to assert type of variable in Python

    - by Morlock
    In using a function, I wish to ensure that the type of the variables are as expected. How to do it right? Here is an example fake function trying to do just this before going on with its role: def my_print(text, begin, end): """Print text in UPPER between 'begin' and 'end' in lower """ for i in (text, begin, end): assert type(i) == type("") out = begin.lower() + text.upper() + end.lower() print out Is this approach valid? Should I use something else than type(i) == type("") ? Should I use try/except instead? Thanks pythoneers

    Read the article

  • Weirdness with cabal, HTF, and HUnit assertions

    - by rampion
    So I'm trying to use HTF to run some HUnit-style assertions % cat tests/TestDemo.hs {-# OPTIONS_GHC -Wall -F -pgmF htfpp #-} module Main where import Test.Framework import Test.HUnit.Base ((@?=)) import System.Environment (getArgs) -- just run some tests main :: IO () main = getArgs >>= flip runTestWithArgs Main.allHTFTests -- all these tests should fail test_fail_int1 :: Assertion test_fail_int1 = (0::Int) @?= (1::Int) test_fail_bool1 :: Assertion test_fail_bool1 = True @?= False test_fail_string1 :: Assertion test_fail_string1 = "0" @?= "1" test_fail_int2 :: Assertion test_fail_int2 = [0::Int] @?= [1::Int] test_fail_string2 :: Assertion test_fail_string2 = "true" @?= "false" test_fail_bool2 :: Assertion test_fail_bool2 = [True] @?= [False] And when I use ghc --make, it seems to work correctly. % ghc --make tests/TestDemo.hs [1 of 1] Compiling Main ( tests/TestDemo.hs, tests/TestDemo.o ) Linking tests/TestDemo ... % tests/TestDemoA ... * Tests: 6 * Passed: 0 * Failures: 6 * Errors: 0 Failures: * Main:fail_int1 (tests/TestDemo.hs:9) * Main:fail_bool1 (tests/TestDemo.hs:12) * Main:fail_string1 (tests/TestDemo.hs:15) * Main:fail_int2 (tests/TestDemo.hs:19) * Main:fail_string2 (tests/TestDemo.hs:22) * Main:fail_bool2 (tests/TestDemo.hs:25) But when I use cabal to build it, not all the tests that should fail, fail. % cat Demo.cabal ... executable test-demo build-depends: base >= 4, HUnit, HTF main-is: TestDemo.hs hs-source-dirs: tests % cabal configure Resolving dependencies... Configuring Demo-0.0.0... % cabal build Preprocessing executables for Demo-0.0.0... Building Demo-0.0.0... [1 of 1] Compiling Main ( tests/TestDemo.hs, dist/build/test-demo/test-demo-tmp/Main.o ) Linking dist/build/test-demo/test-demo ... % dist/build/test-demo/test-demo ... * Tests: 6 * Passed: 3 * Failures: 3 * Errors: 0 Failures: * Main:fail_int2 (tests/TestDemo.hs:23) * Main:fail_string2 (tests/TestDemo.hs:26) * Main:fail_bool2 (tests/TestDemo.hs:29) What's going wrong and how can I fix it?

    Read the article

  • Running PHP Zend Test in Eclipse

    - by Carlos Eiroa
    Is it possible to run PHP Zend test cases (those that extend Zend_Test_PHPUnit_ControllerTestCase, etc.) through Eclipse PDT? I would like to be able to run them in a similar fashion as you run JUnit tests in Eclipse, by right-clicking the test file and selecting "Run as a JUnit test case." I'd love to see the green or red bar instead of having to go to the command line :). Thanks in advance.

    Read the article

  • C++ static code analysis tool on Windows

    - by KTC
    What C++ static code analysis tool are there on Microsoft Windows, and which would you recommend? Please state whether a particular tool relies on cygwin, and whether it cost money. One per post as per for voting up & down. Similar Question: http://stackoverflow.com/questions/141498/what-open-source-c-static-analysis-tools-are-available

    Read the article

  • How do I assert that two arbitrary type objects are equivalent, without requiring them to be equal?

    - by Tomas Lycken
    To accomplish this (but failing to do so) I'm reflecting over properties of an expected and actual object and making sure their values are equal. This works as expected as long as their properties are single objects, i.e. not lists, arrays, IEnumerable... If the property is a list of some sort, the test fails (on the Assert.AreEqual(...) inside the for loop). public void WithCorrectModel<TModelType>(TModelType expected, string error = "") where TModelType : class { var actual = _result.ViewData.Model as TModelType; Assert.IsNotNull(actual, error); Assert.IsInstanceOfType(actual, typeof(TModelType), error); foreach (var prop in typeof(TModelType).GetProperties()) { Assert.AreEqual(prop.GetValue(expected, null), prop.GetValue(actual, null), error); } } If dealing with a list property, I would get the expected results if I instead used CollectionAssert.AreEquivalent(...) but that requires me to cast to ICollection, which in turn requries me to know the type listed, which I don't (want to). It also requires me to know which properties are list types, which I don't know how to. So, how should I assert that two objects of an arbitrary type are equivalent? Note: I specifically don't want to require them to be equal, since one comes from my tested object and one is built in my test class to have something to compare with.

    Read the article

  • DSL to generate test data

    - by queen3
    There're several ways to generate data for tests (not only unit tests), for example, Object Mother, builders, etc. Another useful approach is to write test data as plain text: product: Main; prices: 145, 255; Expire: 10-Apr-2011; qty: 2; includes: Sub product: Sub; prices: 145, 255; Expire: 10-Apr-2011; qty: 2 and then parse it into C# objects. This is easy to use in unit tests (because deep inner collections can be written in single line), this is even more convenient to use in FitNesse-like system (because this DSL naturally fits into wiki), and so on. So I use this and write parser, but it's tedious to write each time. I'm not a big expert in DSL/language parsers, but I think they can help here. What would be the right one to use? I only heard about: DSL (I mean, any DSL) Boo (that I think can do DSL) ANTLR but I don't even know which one to pick and where to start. So the question: is it reasonable to use some kind of DSL to generate test data? What would you suggest to do so? Are there any existing cases?

    Read the article

  • How to create contexts in shoulda macros

    - by Honza
    Asking this question again with smaller code sample: # this is a dummy shoulda macro that creates a context def self.macro_context context "macro" do yield end end # i am expecting this test to fail within the macro context context "some context" do macro_context do should "test" do fail end end end So what I would expect is to see: 1) Error: test: some context macro context should test. (TestClassName) But I am getting only this: So what I would expect is to see: 1) Error: test: some context should test. (TestClassName) Any idea what am I doing wrong?

    Read the article

  • Any teams out there using TypeMock? Is it worth the hefty price tag?

    - by dferraro
    Hi, I hope this question is not 'controversial' - I'm just basically asking - has anyone here purchased TypeMock and been happy (or unhappy) with the results? We are a small dev shop of only 12 developers including the 2 dev managers. We've been using NMock so far but there are limitations. I have done research and started playing with TypeMock and I love it. It's super clean syntax and lets you basically mock everything, which is great for legacy code. The problem is - how do I justify to my boss spending 800-1200$ per license for an API which has 4-5 competitors that are completly free? 800-1200$ is how much Infragistrics or Telerik cost per license - and there sure as hell isn't 4-5 open source comparable UI frameworks... Which is why I find it a bit overpriced, albeit an awesome library... Any opinions / experiences are greatly appreciated. EDIT: after finding MOQ I thought I fell in love - until I found out that it's not fully supported in VB.NET because VB lacks lambda sub routines =(. Is anyone using MOQ for VB.NET? The problem is we are a mixed shop - we use C# for our CRM development and VB for everything else. Any guidence is greatly appreciated again

    Read the article

  • moqing static method call to c# library class

    - by Joe
    This seems like an easy enough issue but I can't seem to find the keywords to effect my searches. I'm trying to unit test by mocking out all objects within this method call. I am able to do so to all of my own creations except for this one: public void MyFunc(MyVarClass myVar) { Image picture; ... picture = Image.FromStream(new MemoryStream(myVar.ImageStream)); ... } FromStream is a static call from the Image class (part of c#). So how can I refactor my code to mock this out because I really don't want to provide a image stream to the unit test.

    Read the article

  • How do I pipe the Java console output to a file?

    - by Ced
    I found a bug in an application that completely freezes the JVM. The produced stacktrace would provide valuable information for the developers and I would like to retrieve it from the Java console. When the JVM crashes, the console is frozen and I cannot copy the contained text anymore. Is there way to pipe the Java console directly to a file or some other means of accessing the console output of a Java application? Update: I forgot to mention, without changing the code. I am a manual tester. Update 2: This is under Windows XP and it's actually a web start application. Piping the output of javaws jnlp-url does not work (empty file).

    Read the article

  • Comparing two objects that are the same in MbUnit

    - by Coppermill
    From MBUnit I am trying to check if the values of two objects are the same using Assert.AreSame(RawDataRow, result); However I am getting the following fail: ====================== Expected Value & Actual Value : {RawDataRow: CentreID = "CentreID1", CentreLearnerRef = "CentreLearnerRef1", ContactID = 1, DOB = 2010-05-05T00:00:00.0000000, Email = "Email1", ErrorCodes = "ErrorCodes1", ErrorDescription = "ErrorDescription1", FirstName = "FirstName1"} Remark : Both values look the same when formatted but they are distinct instances. ====================== I don't want to have to go through each property, can I do this from MbUnit

    Read the article

  • Action works, but test doesn't (Shoulda)

    - by trobrock
    I am trying to test my update action in Rails with this: context "on PUT to :update" do setup do @countdown = Factory(:countdown) @new_countdown = Factory.stub(:countdown) put :update, :id => @countdown.id, :name => @new_countdown.name, :end => @new_countdown.end end should_respond_with :redirect should_redirect_to("the countdowns view") { countdown_url(assigns(:countdown)) } should_assign_to :countdown should_set_the_flash_to /updated/i should "save :countdown with new attributes" do @countdown = Countdown.find(@countdown.id) assert_equal @new_countdown.name, @countdown.name assert_equal 0, (@new_countdown.end - @countdown.end).to_i end end When I actually go through the updating process using the scaffold that was built it updates the record fine, but the tests give me this error: 1) Failure: test: on PUT to :update should save :countdown with new attributes. (CountdownsControllerTest) [/test/functional/countdowns_controller_test.rb:86:in `__bind_1276353837_121269' /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call' /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: on PUT to :update should save :countdown with new attributes. ']: <"Countdown 8"> expected but was <"Countdown 7">.

    Read the article

  • How to test onLowMemory conditions?

    - by Samuh
    I have put some instructions in onLowMemory() callback and want to test the same. Is there a "direct" way to test onLowMemory function of the application subclass? Or will I have to just overload the phone by starting many apps and doing memory intensive tasks? Thanks.

    Read the article

  • Intelligent serial port mocks with Moq

    - by Padu Merloti
    I have to write a lot of code that deals with serial ports. Usually there will be a device connected at the other end of the wire and I usually create my own mocks to simulate their behavior. I'm starting to look at Moq to help with my unit tests. It's pretty simple to use it when you need just a stub, but I want to know if it is possible and if yes how do I create a mock for a hardware device that responds differently according to what I want to test. A simple example: One of the devices I interface with receives a command (move to position x), gives back an ACK message and goes to a "moving" state until it reaches the ordered position. I want to create a test where I send the move command and then keep querying state until it reaches the final position. I want to create two versions of the mock for two different tests, one where I expect the device to reach the final position successfully and the other where it will fail. Too much to ask?

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >