Search Results

Search found 4765 results on 191 pages for 'gh unit'.

Page 61/191 | < Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >

  • Rhino Mocks - Do we really need stubs?

    - by Marcelo Oliveira
    If it's possible to change mock behaviour in Rhino Mocks using mock.Stub().Return(), why do we need Stubs anyway? What do we lose by always using MockRepository.GenerateMock()? One big benefit of using Mocks instead of Stubs is that we will be able to reuse the same instance among all the tests keeping them cleaner and straightforward. The moq framework works in a similar way... we don't have different objects for mocks and stubs. (please, don't answer with a link to Fowler's "Mocks aren't stubs" article)

    Read the article

  • Testing if a UI element is hidden in an OCUnit test

    - by Logan Serman
    I have a button that is hidden under certain circumstances that I wish to test. The button is hidden with [theButton setHidden: YES] in the viewDidLoad method if it is appropriate. For simplicity, lets say that the button is hidden when the buttonIsHidden property is set to true in the view controller. Right now I am trying the following: self.viewController = [[ViewController alloc] init]; self.viewController.buttonIsHidden = YES; [self.viewController loadView]; UIButton *theButton = [...] // function I wrote to retrieve the button based on it's touch up inside action if (theButton) { NSLog(@"%c", theButton.hidden); return (theButton.hidden == true) } return NO; It looks like the hidden property is not what it should be, the NSLog lines from the above code are blank. But, if I output another property like the height, it outputs the correct value so I know it is getting the right button. How do I access the hidden property of the button in this case?

    Read the article

  • Run PHPUnit Tests in Certain Order

    - by dragonmantank
    Is there a way to get the tests inside of a TestCase to run in a certain order? For example, I want to seperate the lifecycle of an object from creation to use to destruction but need to make sure that the object is set up first before I run the other tests.

    Read the article

  • Mock a void method which change the input value

    - by Kar
    Hi, How could I mock a void method with parameters and change the value parameters? My void method looks like this: public interface IFoo { void GetValue(int x, object y) // takes x and do something then access another class to get the value of y } I prepared a delegate class: private delegate void GetValueDelegate(int x, object y); private void GetValue(int x, object y) { // process x // prepare a new object obj if (y == null) y = new Object(); if (//some checks) y = obj; } I wrote something like this: Expect.Call(delegate {x.GetValue(5, null);}).Do (new GetValueDelegate(GetValue)).IgnoreArguments().Repeat.Any(); But seems like it's not working. Any clue on what could be wrong?

    Read the article

  • Running single test class or group with Surefire and TestNG

    - by Slartibartfast
    I want to run single test class from command line using Maven and TestNG Things that doesn't work: mvn -Dtest=ClassName test I have defined groups in pom.xml, and this class isn't in one of those groups. So it got excluded on those grounds. mvn -Dgroups=skipped-group test mvn -Dsurefire.groups=skipped-group test when config is <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.7.1</version> <configuration> <groups>functest</groups> </configuration> </plugin> Parameters work fine in there are no groups defined in pom.xml. Similarly, when surefire is configured with <configuration> <includes> <include>**/*UnitTest.java</include> </includes> </configuration> I can add another test with -Dtest parameter, but cannot add group. In any combination, I can narrow down tests to be executed with groups, but not expand them. What's wrong with my configuration? Is there a way to run a single test or group outside of those defined in pom.xml? Tried on Ubuntu 10.04 with Maven 2.2.1, TestNG 5.14.6 and Surefire 2.7.1

    Read the article

  • defining a simple implicit Arbitary

    - by FredOverflow
    I have a type Foo with a constructor that takes an Int. How do I define an implicit Arbitrary for Foo to be used with scalacheck? implicit def arbFoo: Arbitrary[Foo] = ??? I came up with the following solution, but it's a bit too "manual" and low-level for my taste: val fooGen = for (i <- Gen.choose(Int.MinValue, Int.MaxValue)) yield new Foo(i) implicit def arbFoo: Arbitrary[Foo] = Arbitrary(fooGen) Ideally, I would want a higher-order function where I just have to plug in an Int => Foo function. I managed to cut it down to: implicit def arbFoo = Arbitrary(Gen.resultOf((i: Int) => new Foo(i))) But I still feel like there has got to be a slightly simpler way.

    Read the article

  • Caching result of setUp() using Python unittest

    - by dbr
    I currently have a unittest.TestCase that looks like.. class test_appletrailer(unittest.TestCase): def setup(self): self.all_trailers = Trailers(res = "720", verbose = True) def test_has_trailers(self): self.failUnless(len(self.all_trailers) > 1) # ..more tests.. This works fine, but the Trailers() call takes about 2 seconds to run.. Given that setUp() is called before each test is run, the tests now take almost 10 seconds to run (with only 3 test functions) What is the correct way of caching the self.all_trailers variable between tests? Removing the setUp function, and doing.. class test_appletrailer(unittest.TestCase): all_trailers = Trailers(res = "720", verbose = True) ..works, but then it claims "Ran 3 tests in 0.000s" which is incorrect.. The only other way I could think of is to have a cache_trailers global variable (which works correctly, but is rather horrible): cache_trailers = None class test_appletrailer(unittest.TestCase): def setUp(self): global cache_trailers if cache_trailers is None: cache_trailers = self.all_trailers = all_trailers = Trailers(res = "720", verbose = True) else: self.all_trailers = cache_trailers

    Read the article

  • Is Assert.Fail() considered bad practice?

    - by Mendelt
    I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the body. When trying out xUnit.Net I found they hadn't implemented Assert.Fail. Of course you can always Assert.IsTrue(false) but this doesn't communicate my intention as well. I got the impression Assert.Fail wasn't implemented on purpose. Is this considered bad practice? If so why? @Martin Meredith That's not exactly what I do. I do write a test first and then implement code to make it work. Usually I think of several tests at once. Or I think about a test to write when I'm working on something else. That's when I write an empty failing test to remember. By the time I get to writing the test I neatly work test-first. @Jimmeh That looks like a good idea. Ignored tests don't fail but they still show up in a separate list. Have to try that out. @Matt Howells Great Idea. NotImplementedException communicates intention better than assert.Fail() in this case @Mitch Wheat That's what I was looking for. It seems it was left out to prevent it being abused in another way I abuse it.

    Read the article

  • Multiple asserts in single test?

    - by Gern Blandston
    Let's say I want to write a function that validates an email address with a regex. I write a little test to check my function and write the actual function. Make it pass. However, I can come up with a bunch of different ways to test the same function ([email protected]; [email protected]; test.test.com, etc). Do I put all the incantations that I need to check in the same, single test with several ASSERTS or do I write a new test for every single thing I can think of? Thanks!

    Read the article

  • How to test a site rigorously?

    - by Sarfraz
    Hello, I recently created a big portal site. It's time for putting it to test. How do you guys test a site rigorously? What are the ways and tools for that? Can we sort of mimic hundreds of virtual users visiting the site to see its load handling? The test should be for both security and speed Thanks in advance.

    Read the article

  • JUnit terminates child threads

    - by Marco
    Hi to all, When i test the execution of a method that creates a child thread, the JUnit test ends before the child thread and kills it. How do i force JUnit to wait for the child thread to complete its execution? Thanks

    Read the article

  • Wrapping text and div as a unit

    - by mathee
    I have the following that I would like wrapped as units. <div class='tag-box'> <a href=#>Axe Committee</a> <div class='circle'><a href=#>x</a></div> </div> The CSS for these classes are: .tag-box { display:inline; } .circle { display:inline; padding-left:4px; padding-right:4px; background:rgb(196,15,24); /*dark red*/ -moz-border-radius:10px; -webkit-border-radius:10px; } .circle a { font-size:10px; text-decoration:none; color:#fff; position:relative; top:-2px; } I can have upwards of 20 or 30 of these tag-boxes displayed inline. The problem is that the wrapping will break the words from each other or even break the red circle from the link. This makes it hard to differentiate which circle belongs to which link. (In the future, each circle corresponds to a different action with respect to the link.) See below. How do I prevent this kind of wrapping from occurring?

    Read the article

  • Java: How to test methods that call System.exit()?

    - by Chris Conway
    I've got a few methods that should call System.exit() on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since System.exit() terminates the JVM, not just the current thread. Are there any common patterns for dealing with this? For example, can I subsitute a stub for System.exit()? [EDIT] The class in question is actually a command-line tool which I'm attempting to test inside JUnit. Maybe JUnit is simply not the right tool for the job? Suggestions for complementary regression testing tools are welcome (preferably something that integrates well with JUnit and EclEmma).

    Read the article

  • Unittest and mock

    - by user1410756
    I'm testing with unittest in python and it's ok. Now, I have introduced mock and I need to resolve a question. This is my code: from mock import Mock import unittest class Matematica(object): def __init__(self, op1, op2): self.op1 = op1 self.op2 = op2 def adder(self): return self.op1 + self.op2 def subs(self): return abs(self.op1 - self.op2) def molt(self): return self.op1 * self.op2 def divid(self): return self.op1 / self.op2 class TestMatematica(unittest.TestCase): """Test della classe Matematica""" def testing(self): """Somma""" mat = Matematica(10,20) self.assertEqual(mat.adder(),30) """Sottrazione""" self.assertEqual(mat.subs(),10) class test_mock(object): def __init__(self, matematica): self.matematica = matematica def execute(self): self.matematica.adder() self.matematica.adder() self.matematica.subs() if __name__ == "__main__": result = unittest.TextTestRunner(verbosity=2).run(TestMatematica('testing')) a = Matematica(10,20) b = test_mock(a) b.execute() mock_foo = Mock(b.execute)#return_value = 'rafa') mock_foo() print mock_foo.called print mock_foo.call_count print mock_foo.method_calls This code is functionally and result of print is: True, 1, [] . Now, I need to count how many times are called self.matematica.adder() and self.matematica.subs() . THANKS

    Read the article

  • Grails 1.3.3: controller.redirectArgs.action not populated

    - by Matthias Hryniszak
    Does anyone knows what happened to controller.redirectArgs.action in the latest version of Grails (1.3.3)? It used to work properly but now I get NPE when I use it. class FooController { def someRedirect = { redirect(action:"bar") } } class FooControllerTests extends grails.test.ControllerUnitTestCase { void testSomeRedirect() { controller.someRedirect() assertEquals "bar", controller.redirectArgs.action } } In this case controller.redirectArgs is already null...

    Read the article

  • Test assertions for tuples with floats

    - by Space_C0wb0y
    I have a function that returns a tuple that, among others, contains a float value. Usually I use assertAlmostEquals to compare those, but this does not work with tuples. Also, the tuple contains other data-types as well. Currently I am asserting every element of the tuple individually, but that gets too much for a list of such tuples. Is there any good way to write assertions for such cases?

    Read the article

  • Testing methods called on yielded object

    - by Todd R
    I have the following controller test case: def test_showplain Cleaner.expect(:parse).with(@somecontent) Cleaner.any_instance.stubs(:plainversion).returns(@returnvalue) post :showplain, {:content => @somecontent} end This works fine, except that I want the "stubs(:plainversion)" to be an "expects(:plainversion)". Here's the controller code: def showplain Cleaner.parse(params[:content]) do | cleaner | @output = cleaner.plainversion end end And the Cleaner is simply: class Cleaner ### other code and methods ### def self.parse(@content) cleaner = Cleaner.new(@content) yield cleaner cleaner.close end def plainversion ### operate on @content and return ### end end Again, I can't figure out how to reliably test the "cleaner" that is made available from the "parse" method. Any suggestions?

    Read the article

  • Why should I be using testing frameworks in PHP?

    - by Industrial
    Hi everyone, I have recently heard a lot of people argue about using PHP testing features like PHPunit and SimpleTest together with their IDE of choice (Eclipse for me). After googling the subject, I have still a hard time understanding the pros and cons of using these testing frameworks to speed up development. If anyone could explain this for me in a more basic level, I would really appreciate it. I am using PHP5 for the notice. Thanks a lot!

    Read the article

  • Nested Resource testing RSpec

    - by Joseph DelCioppio
    I have two models: class Solution < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => :user_id end class User < ActiveRecord::Base has_many :solutions end with the following routing: map.resources :users, :has_many => :solutions and here is the SolutionsController: class SolutionsController < ApplicationController before_filter :load_user def index @solutions = @user.solutions end private def load_user @user = User.find(params[:user_id]) unless params[:user_id].nil? end end Can anybody help me with writing a test for the index action? So far I have tried the following but it doesn't work: describe SolutionsController do before(:each) do @user = Factory.create(:user) @solutions = 7.times{Factory.build(:solution, :owner => @user)} @user.stub!(:solutions).and_return(@solutions) end it "should find all of the solutions owned by a user" do @user.should_receive(:solutions) get :index, :user_id => @user.id end end And I get the following error: Spec::Mocks::MockExpectationError in 'SolutionsController GET index, when the user owns the software he is viewing should find all of the solutions owned by a user' #<User:0x000000041c53e0> expected :solutions with (any args) once, but received it 0 times Thanks in advance for all the help. Joe

    Read the article

  • test cases for testing a strtok-alike function [C++]

    - by Neeraj
    Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters = "\t\r\n"); //constructor string getNextToken(); void reset(); bool empty(); } Can someone list some good testcases to test the above class. A few I could think of are: empty string, empty delimiters, repeated delimiters, consecutive delimiters, string with only delimiters. However, the interviewer expected some more(better ones). Can you help out. Thanks.

    Read the article

< Previous Page | 57 58 59 60 61 62 63 64 65 66 67 68  | Next Page >