Search Results

Search found 5783 results on 232 pages for 'translation unit'.

Page 71/232 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • Are there any open source SimpleTest Test Cases that test PHP SPL interfaces

    - by JW
    I have quite a few objects in my system that implement the PHP SPL Iterator interface. As I write them I also write tests. I know that writing tests is generally NOT a cut 'n paste job. But, when it comes to testing classes that implement Standard PHP Library interfaces, surely it makes sense to have a few script snippets that can be borrowed and dropped in to a Test class - purely to test that particular interface. It seems sensible to have these publicly available. So, I was wondering if you knew of any?

    Read the article

  • How to Return Variable for all tests to use Unittest

    - by chrissygormley
    Hello, I have a Python script and I am trying to set a variable so that if the first test fail's the rest of then will be set to fail. The script I have so far is: class Tests(): def function: result function.......... def errorHandle(self): return self.error def sudsPass(self): try: result = self.client.service.GetStreamUri(self.stream, self.token) except suds.WebFault, e: assert False except Exception, e: pass finally: if 'result' in locals(): self.error = True self.errorHandle() assert True else: self.error = False self.errorHandle() assert False def sudsFail(self): try: result = self.client.service.GetStreamUri(self.stream, self.token) except suds.WebFault, e: assert False except Exception, e: pass finally: if 'result' in locals() or self.error == False: assert False else: assert True class GetStreamUri(TestGetStreamUri): def runTest(self): self.sudsPass() class GetStreamUriProtocolFail(TestGetStreamUri): def runTest(self): self.stream.Transport.Protocol = "NoValue" self.errorHandle() self.sudsFail() if __name__ == '__main__': unittest.main() I am trying to get self.error to be set to False if the first test fail. I understand that it is being set in another test but I was hoping someone could help me find a solution to this problem using some other means. Thanks PS. Please ignore the strange tests. There is a problem with the error handling at the moment.

    Read the article

  • Stubbing a before_filter with RSpec

    - by TheDelChop
    Guys, I'm having trouble understanding why I can't seem to stub this controller method :load_user, since all of my tests fail if I change the actual implementation of :load_user to not return and instance of @user. Can anybody see why my stub (controller.stub!(:load_user).and_return(@user)) seems to fail to actually get called when RSpec makes a request to the controller? require 'spec_helper' describe TasksController do before(:each) do @user = Factory(:user) sign_in @user @task = Factory(:task) User.stub_chain(:where, :first).and_return(@user) controller.stub!(:load_user).and_return(@user) end #GET Index describe "GET Index" do before(:each) do @tasks = 7.times{Factory(:task, :user = @user)} @user.stub!(:tasks).and_return(@tasks) end it "should should find all of the tasks owned by a user" do @user.should_receive(:tasks).and_return(@tasks) get :index, :user_id = @user.id end it "should assign all of the user's tasks to the view" do get :index, :user_id = @user.id assigns[:tasks].should be(@tasks) end end #GET New describe "GET New" do before(:each) do @user.stub_chain(:tasks, :new).and_return(@task) end it "should return a new Task" do @user.tasks.should_receive(:new).and_return(@task) get :new, :user_id = @user.id end end #POST Create describe "POST Create" do before(:each) do @user.stub_chain(:tasks, :new).and_return(@task) end it "should create a new task" do @user.tasks.should_receive(:new).and_return(@task) post :create, :user_id = @user.id, :task = @task.to_s end it "saves the task" do @task.should_receive(:save) post :create, :user_id = @user.id, :task = @task end context "when the task is saved successfully" do before(:each) do @task.stub!(:save).and_return(true) end it "should set the flash[:notice] message to 'Task Added Successfully'"do post :create, :user_id = @user.id, :task = @task flash[:notice].should == "Task Added Successfully!" end it "should redirect to the user's task page" do post :create, :user_id = @user.id, :task = @task response.should redirect_to(user_tasks_path(@user.id)) end end context "when the task isn't saved successfully" do before(:each) do @task.stub(:save).and_return(false) end it "should return to the 'Create New Task' page do" do post :create, :user_id = @user.id, :task = @task response.should render_template('new') end end end it "should attempt to authenticate and load the user who owns the tasks" do context "when the tasks belong to the currently logged in user" do it "should set the user instance variable to the currently logged in user" do pending end end context "when the tasks belong to another user" do it "should set the flash[:notice] to 'Sorry but you can't view other people's tasks.'" do pending end it "should redirect to the home page" do pending end end end end class TasksController < ApplicationController before_filter :load_user def index @tasks = @user.tasks end def new @task = @user.tasks.new end def create @task = @user.tasks.new if @task.save flash[:notice] = "Task Added Successfully!" redirect_to user_tasks_path(@user.id) else render :action => 'new' end end private def load_user if current_user.id == params[:user_id].to_i @user = User.where(:id => params[:user_id]).first else flash[:notice] = "Sorry but you can't view other people's tasks." redirect_to root_path end end end Can anybody see why my stub doesnt' work? Like I said, my tests only pass if I make sure that load_user works, if not, all my tests fail which makes my think that RSpec isn't using the stub I created. Thanks, Joe

    Read the article

  • Why do I get a Illegal Access Error when running my Android tests?

    - by Janusz
    I get the following stack trace when running my Android tests on the Emulator: java.lang.NoClassDefFoundError: client.HttpHelper at client.Helper.<init>(Helper.java:14) at test.Tests.setUp(Tests.java:15) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:164) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:151) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:425) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1520) Caused by: java.lang.IllegalAccessError: cross-loader access from pre-verified class at dalvik.system.DexFile.defineClass(Native Method) at dalvik.system.DexFile.loadClass(DexFile.java:193) at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203) at java.lang.ClassLoader.loadClass(ClassLoader.java:573) at java.lang.ClassLoader.loadClass(ClassLoader.java:532) ... 11 more I run my tests from an extra project. And it seems there are some problems with loading the classes from the other project. I have run the tests before but now they are failing. The project under tests runs without problems. Line 14 of the Helper Class is: this.httpHelper = new HttpHelper(userProfile); I start a HttpHelper class that is responsible for executing httpqueries. I think somehow this helper class is not available anymore, but I have no clue why.

    Read the article

  • Django Fancy String Diff During Test Execution in Console

    - by Koobz
    Anyone know of any pre-existing tools out there what will highlight differences in output when running Django tests? I'm comparing some JSON output and it's tough to find things like extra spaces. I was about to just copy and paste this into an existing diff tool but I figured this might be on someone's radar.

    Read the article

  • How to mock WCF Web Services with Rhino Mocks.

    - by Will
    How do I test a class that utilizes proxy clients generated by a Web Service Reference? I would like to mock the client, but the generated client interface doesn't contain the close method, which is required to properly terminate the proxy. If I don't use the interface, but instead a concrete reference, I get access to the close method but loose the ability to mock the proxy. I'm trying to test a class similar to this: public class ServiceAdapter : IServiceAdapter, IDisposable { // ILoggingServiceClient is generated via a Web Service reference private readonly ILoggingServiceClient _loggingServiceClient; public ServiceAdapter() : this(new LoggingServiceClient()) {} internal ServiceAdapter(ILoggingServiceClient loggingServiceClient) { _loggingServiceClient = loggingServiceClient; } public void LogSomething(string msg) { _loggingServiceClient.LogSomething(msg); } public void Dispose() { // this doesn't compile, because ILoggingServiceClient doesn't contain Close(), // yet Close is required to properly terminate the WCF client _loggingServiceClient.Close(); } }

    Read the article

  • Reflection in unit tests for checking code coverage

    - by Gary
    Here's the scenario. I have VO (Value Objects) or DTO objects that are just containers for data. When I take those and split them apart for saving into a DB that (for lots of reasons) doesn't map to the VO's elegantly, I want to test to see if each field is successfully being created in the database and successfully read back in to rebuild the VO. Is there a way I can test that my tests cover every field in the VO? I had an idea about using reflection to iterate through the fields of the VO's as part of the solution, but maybe you guys have solved the problem before? I want this test to fail when I add fields in the VO, and don't remember to add checks for it in my tests.

    Read the article

  • DDSteps date question.

    - by Srini
    DDStep Date Question: Currently trying to pass just the date from excel. But getting the below error while doing it. Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property ...no matching editors or conversion strategy found spring for date conversion I even tried to add customEditorConfigurer in the ddsteps-context file. Still getting error. But in their pet store example looks like it works fine. Any help is appreciated. <entry key="java.util.Date"> <bean class="org.springframework.beans.propertyeditors.CustomDateEditor"> <constructor-arg> <bean class="java.text.SimpleDateFormat"> <constructor-arg value="yyyy-MM-dd" /> </bean> </constructor-arg> <constructor-arg value="false" /> </bean> </entry>

    Read the article

  • Error using MVCContrib TestHelper

    - by Brian McCord
    While trying to implement the second answer to a previous question, I am receiving an error. I have implemented the methods just as the post shows, and the first three work properly. The fourth one (HomeController_Delete_Action_Handler_Should_Redirect_If_Model_Successfully_Delete) gives this error: Could not find a parameter named 'controller' in the result's Values collection. If I change the code to: actual .AssertActionRedirect() .ToAction("Index"); it works properly, but I don't like the "magic string" in there and prefer to use the lambda method that the other poster used. My controller method looks like this: [HttpPost] public ActionResult Delete(State model) { try { if( model == null ) { return View( model ); } _stateService.Delete( model ); return RedirectToAction("Index"); } catch { return View( model ); } } What am I doing wrong?

    Read the article

  • Why is django.test.client.Client not keeping me logged in.

    - by Mystic
    I'm using django.test.client.Client to test whether some text shows up when a user is logged in. However, I the Client object doesn't seem to be keeping me logged in. This test passes if done manually with Firefox but not when done with the Client object. class Test(TestCase): def test_view(self): user.set_password(password) user.save() client = self.client # I thought a more manual way would work, but no luck # client.post('/login', {'username':user.username, 'password':password}) login_successful = client.login(username=user.username, password=password) # this assert passes self.assertTrue(login_successful) response = client.get("/path", follow=True) #whether follow=True or not doesn't seem to work self.assertContains(response, "needle" ) When I print response it returns the login form that is hidden by: {% if not request.user.is_authenticated %} ... form ... {% endif %} This is confirmed when I run ipython manage.py shell. The problem seems to be that the Client object is not keeping the session authenticated.

    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

  • 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

  • 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

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >