Search Results

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

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

  • where to put the unittest for library in rails

    - by lidaobing
    Hello, I am a ruby and rails newbie. And I am working on a rails application with RadRails. RadRails has a "Switch to Test" function for my controller, model, etc. but not for my library. if I have class Foo::Bar in /lib/foo/bar.rb, where should I put the unittest for it? or should I separate the foo library in a separated project? Thanks.

    Read the article

  • Automatic profiling visual studio 2008

    - by phil
    Is there a way to do automatic profiling in visual studio 2008? I know how the profiling works both from the command line and using the GUI in VS08. What I want to accomplish: After my nightly build I want to complete some profiling (instrumental) to see if some functions (will most likely always be the same) have changed in some negative way (or positive of course).

    Read the article

  • Testing ActionMailer's receive method (Rails)

    - by Brian Armstrong
    There is good documentation out there on testing ActionMailer send methods which deliver mail. But I'm unable to figure out how to test a receive method that is used to parse incoming mail. I want to do something like this: require 'test_helper' class ReceiverTest < ActionMailer::TestCase test "parse incoming mail" do email = TMail::Mail.parse(File.open("test/fixtures/emails/example1.txt",'r').read) assert_difference "ProcessedMail.count" do Receiver.receive email end end end But I get the following error on the line which calls Receiver.receive NoMethodError: undefined method `index' for #<TMail::Mail:0x102c4a6f0> /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/stringio.rb:128:in `gets' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/mail.rb:392:in `parse_header' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/mail.rb:139:in `initialize' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/stringio.rb:43:in `open' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/port.rb:340:in `ropen' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/mail.rb:138:in `initialize' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/mail.rb:123:in `new' /Library/Ruby/Gems/1.8/gems/tmail-1.2.7.1/lib/tmail/mail.rb:123:in `parse' /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:417:in `receive' Tmail is parsing the test file I have correctly. So that's not it. Thanks!

    Read the article

  • Force orientation change in testcase with fragments

    - by user1202032
    I have an Android test project in which I wish to programatically change the orientation. My test: public class MainActivityLandscapeTest extends ActivityInstrumentationTestCase2<MainActivity> { public MainActivityLandscapeTest() { super(MainActivity.class); } private MainActivity mActivity; private Fragment mDetailFragment; private Fragment mListFragment; private Solo mSolo; @Override protected void setUp() throws Exception { super.setUp(); mSolo = new Solo(getInstrumentation(), getActivity()); mSolo.setActivityOrientation(Solo.LANDSCAPE); mActivity = getActivity(); mListFragment = (Fragment) mActivity.getSupportFragmentManager() .findFragmentById(R.id.listFragment); mDetailFragment = (Fragment) mActivity.getSupportFragmentManager() .findFragmentById(R.id.detailFragment); } public void testPreConditions() { assertTrue(mActivity != null); assertTrue(mSolo != null); assertTrue(mListFragment != null); assertTrue(getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); } /** * Only show detailFragment in landscape mode */ public void testOrientation() { assertTrue(mListFragment.isVisible()); assertTrue(mDetailFragment.isVisible()); } } The layouts for the activity is in seperate folders, layout-port and layout-land layout-port fragment_main.xml layout-land fragment_main.xml In landscape mode, the layout contains 2 fragments (Detail and list) while in portrait it contains 1(List only). If the device/emulator is already in landscape mode before testing begins, this test passes. If in portrait, it fails with a NullPointerException on mListFragment and mDetailFragment. Adding a delay (waitForIdleSync() and/or waitForActivity()) did NOT seem to solve my problem. How do i force the orientation to landscape in my test, while still being able to find the fragments using findFragmentById()?

    Read the article

  • Using Assert to compare two objects

    - by baron
    Hi everyone, Writing test cases for my project, one test I need is to test deletion. This may not exactly be the right way to go about it, but I've stumbled upon something which isn't making sense to me. Code is like this: [Test] private void DeleteFruit() { BuildTestData(); var f1 = new Fruit("Banana",1,1.5); var f2 = new Fruit("Apple",1,1.5); fm.DeleteFruit(f1,listOfFruit); Assert.That(listOfFruit[1] == f2); } Now the fruit object I create line 5 is the object that I know should be in that position (with this specific dataset) after f1 is deleted. Also if I sit and debug, and manually compare objects listOfFruit[1] and f2 they are the same. But that Assert line fails. What gives?

    Read the article

  • Is there a library available which easily can record and replay results of API calls?

    - by Billy ONeal
    I'm working on writing various things that call relatively complicated Win32 API functions. Here's an example: //Encapsulates calling NtQuerySystemInformation buffer management. WindowsApi::AutoArray NtDll::NtQuerySystemInformation( SystemInformationClass toGet ) const { AutoArray result; ULONG allocationSize = 1024; ULONG previousSize; NTSTATUS errorCheck; do { previousSize = allocationSize; result.Allocate(allocationSize); errorCheck = WinQuerySystemInformation(toGet, result.GetAs<void>(), allocationSize, &allocationSize); if (allocationSize <= previousSize) allocationSize = previousSize * 2; } while (errorCheck == 0xC0000004L); if (errorCheck != 0) { THROW_MANUAL_WINDOWS_ERROR(WinRtlNtStatusToDosError(errorCheck)); } return result; } //Client of the above. ProcessSnapshot::ProcessSnapshot() { using Dll::NtDll; NtDll ntdll; AutoArray systemInfoBuffer = ntdll.NtQuerySystemInformation( NtDll::SystemProcessInformation); BYTE * currentPtr = systemInfoBuffer.GetAs<BYTE>(); //Loop through the results, creating Process objects. SYSTEM_PROCESSES * asSysInfo; do { // Loop book keeping asSysInfo = reinterpret_cast<SYSTEM_PROCESSES *>(currentPtr); currentPtr += asSysInfo->NextEntryDelta; //Create the process for the current iteration and fill it with data. std::auto_ptr<ProcImpl> currentProc(ProcFactory( static_cast<unsigned __int32>(asSysInfo->ProcessId), this)); NormalProcess* nptr = dynamic_cast<NormalProcess*>(currentProc.get()); if (nptr) { nptr->SetProcessName(asSysInfo->ProcessName); } // Populate process threads for(ULONG idx = 0; idx < asSysInfo->ThreadCount; ++idx) { SYSTEM_THREADS& sysThread = asSysInfo->Threads[idx]; Thread thread( currentProc.get(), static_cast<unsigned __int32>(sysThread.ClientId.UniqueThread), sysThread.StartAddress); currentProc->AddThread(thread); } processes.push_back(currentProc); } while(asSysInfo->NextEntryDelta != 0); } My problem is in mocking out the NtDll::NtQuerySystemInformation method -- namely, that the data structure returned is complicated (Well, here it's actually relatively simple but it can be complicated), and writing a test which builds the data structure like the API call does can take 5-6 times as long as writing the code that uses the API. What I'd like to do is take a call to the API, and record it somehow, so that I can return that recorded value to the code under test without actually calling the API. The returned structures cannot simply be memcpy'd, because they often contain inner pointers (pointers to other locations in the same buffer). The library in question would need to check for these kinds of things, and be able to restore pointer values to a similar buffer upon replay. (i.e. check each pointer sized value if it could be interpreted as a pointer within the buffer, change that to an offset, and remember to change it back to a pointer on replay -- a false positive rate here is acceptable) Is there anything out there that does anything like this?

    Read the article

  • Is there a JUnit equivalent to NUnit's testcase attribute?

    - by Steph
    I've googled for JUnit test case, and it comes up with something that looks a lot more complicated to implement - where you have to create a new class that extends test case which you then call: public class MathTest extends TestCase { protected double fValue1; protected double fValue2; protected void setUp() { fValue1= 2.0; fValue2= 3.0; } } public void testAdd() { double result= fValue1 + fValue2; assertTrue(result == 5.0); } but what I want is something really simple, like the NUnit test cases [TestCase(1,2)] [TestCase(3,4)] public void testAdd(int fValue1, int fValue2) { double result= fValue1 + fValue2; assertIsTrue(result == 5.0); } Is there any way to do this in JUnit?

    Read the article

  • TestNG - Factories and Dataproviders

    - by Tim K
    Background Story I'm working at a software firm developing a test automation framework to replace our old spaghetti tangled system. Since our system requires a login for almost everything we do, I decided it would be best to use @BeforeMethod, @DataProvider, and @Factory to setup my tests. However, I've run into some issues. Sample Test Case Lets say the software system is a baseball team roster. We want to test to make sure a user can search for a team member by name. (Note: I'm aware that BeforeMethods don't run in any given order -- assume that's been taken care of for now.) @BeforeMethod public void setupSelenium() { // login with username & password // acknowledge announcements // navigate to search page } @Test(dataProvider="players") public void testSearch(String playerName, String searchTerm) { // search for "searchTerm" // browse through results // pass if we find playerName // fail (Didn't find the player) } This test case assumes the following: The user has already logged on (in a BeforeMethod, most likely) The user has already navigated to the search page (trivial, before method) The parameters to the test are associated with the aforementioned login The Problems So lets try and figure out how to handle the parameters for the test case. Idea #1 This method allows us to associate dataproviders with usernames, and lets us use multiple users for any specific test case! @Test(dataProvider="players") public void testSearch(String user, String pass, String name, String search) { // login with user/pass // acknowledge announcements // navigate to search page // ... } ...but there's lots of repetition, as we have to make EVERY function accept two extra parameters. Not to mention, we're also testing the acknowledge announcements feature, which we don't actually want to test. Idea #2 So lets use the factory to initialize things properly! class BaseTestCase { public BaseTestCase(String user, String password, Object[][] data); } class SomeTest { @Factory public void ... } With this, we end up having to write one factory per test case... Although, it does let us have multiple users per test-case. Conclusion I'm about fresh out of ideas. There was another idea I had where I was loading data from an XML file, and then calling the methods from a program... but its getting silly. Any ideas?

    Read the article

  • How to write automated tests for SQL queries?

    - by James
    The current system we are adopting at work is to write some extremely complex queries which perform multiple calculations and have multiple joins / sub-queries. I don't think I am experienced enough to say if this is correct or not so I am agreeing and attempting to function with this system as it has clear benefits. The problem we are having at the moment is that the person writing the queries makes a lot of mistakes and assumes everything is correct. We have now assigned a tester to analyse all of the queries but this still proves extremely time consuming and stressful. I would like to know how we could create an automated procedure (without specifically writing it with code if possible as I can work out how to do that the long way) to verify a set of 10+ different inputs, verify the output data and say if the calculations are correct. I know I could write a script using specific data in the database and create a script using c# (the db is SQL Server) and verify all the values coming out but I would like to know what the official "standard" is as my experience is lacking in this area and I would like to improve. I am happy to add more information if required, add a comment if necessary. Thank you. Edit: I am using c#

    Read the article

  • Argument constraints in RhinoMock methods

    - by Khash
    I am mocking a repository that should have 1 entity in it for the test scenario. The repository has to return this entity based on a known id and return nothing when other ids are passed in. I have tried doing something like this: _myRepository.Expect(item => item.Find(knownId)).Return(knownEntity); _myRepository.Expect(item => item.Find(Arg<Guid>.Is.Anything)).Return(null); It seems however the second line is overriding the first and the repository always returns null. I don't want to mock all the different possible IDs asked (they could go up to hundreds) when the test scenario is only concerned with the value of one Id.

    Read the article

  • Is it possible to run NUnit 2.5.3 tests in Gallio?

    - by Allrameest
    When I try to run NUnit tests in resharper I get this: Detected a probable test framework assembly version mismatch. Referenced test frameworks: 'nunit.framework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77'. Supported test frameworks: 'nunit.framework, Version=2.5.0.0-2.5.2.65535', 'nunit.framework, Version=2.4.8.0-2.4.8.65535'. I use Gallio v3.1 build 397.

    Read the article

  • Best way to test instance methods without running __init__

    - by KenFar
    I've got a simple class that gets most of its arguments via init, which also runs a variety of private methods that do most of the work. Output is available either through access to object variables or public methods. Here's the problem - I'd like my unittest framework to directly call the private methods called by init with different data - without going through init. What's the best way to do this? So far, I've been refactoring these classes so that init does less and data is passed in separately. This makes testing easy, but I think the usability of the class suffers a little. EDIT: Example solution based on Ignacio's answer: import types class C(object): def __init__(self, number): new_number = self._foo(number) self._bar(new_number) def _foo(self, number): return number * 2 def _bar(self, number): print number * 10 #--- normal execution - should print 160: ------- MyC = C(8) #--- testing execution - should print 80 -------- MyC = object.__new__(C) MyC._bar(8)

    Read the article

  • How to get selenium to click on an object other than by ID

    - by Zombies
    So here is a little challenge. I have an image. It has 2 attributes: a random ID - not helpful an image url - but it is a button, and other buttons use the same image url, not helpful a CSS class - also used by too many other things to be helpful a style - neither helpful nor unique This image is however inside of an anchor tag, but the anchor tab isn't to a page, it just runs some javascript. Bellow is the html in question: <a id="template:j_id__ctru168pc2" title="Click for the Manual Class LOV" class="xei" style="text-decoration: none;" onclick="return false;" href="#"> <img id="template:j_id__ctru169pc2" class="xgs" style="border: 0pt none;" src="images/lov_ena.png"> </a> How can I click this image without using the ID?

    Read the article

  • Best way to do TDD in express versions of visual studio(eg VB Express)

    - by Nathan W
    I have been looking in to doing some test driven development for one of the applications that I'm currently writing(OLE wrapper for an OLE object). The only problem is that I am using the express versions of Visual Studio(for now), at the moment I am using VB express but sometimes I use C# express. Is it possible to do TDD in the express versions? If so what are the bast was to go about it? Cheers. EDIT. By the looks of things I will have to buy the full visual studio so that I can do integrated TDD, hopefully there is money in the budget to buy a copy :). For now I think I will use Nunit like everyone is saying.

    Read the article

  • Using fixtures with factory_girl

    - by deb
    When building the following factory: Factory.define :user do |f| f.sequence(:name) { |n| "foo#{n}" } f.resume_type_id { ResumeType.first.id } end ResumeType.first returns nil and I get an error. ResumeType records are loaded via fixtures. I checked using the console and the entries are there, the table is not empty. I've found a similar example in the factory_girl mailing list, and it's supposed to work. What am I missing? Do I have to somehow tell factory_girl to set up the fixtures before running the tests?

    Read the article

  • How to build a test suite in watir?

    - by karlthorwald
    I have some single watir.rb scripts that use IE and are written in a standard watir way. How do I create a test suite that combines them? Is it possible to enumerate the files that should be included in the test suite? Is it possible to auto include single test files into a test suite by subidr? Can I cascade (include other watir suites in watir suites)?

    Read the article

  • Get/save parameters to an expected JMock method call?

    - by Tayeb
    Hi, I want to test an "Adapter" object that when it receives an xml message, it digest it to a Message object, puts message ID + CorrelationID both with timestamps and forwards it to a Client object.=20 A message can be correlated to a previous one (e.g. m2.correlationID =3D m1.ID). I mock the Client, and check that Adapter successfully calls "client.forwardMessage(m)" twice with first message with null correlationID, and a second with a not-null correlationID. However, I would like to precisely test that the correlationIDs are set correctly, by grabing the IDs (e.g. m1.ID). But I couldn't find anyway to do so. There is a jira about adding the feature, but no one commented and it is unassigned. Is this really unimplemented? I read about the alternative of redesigning the Adapter to use an IdGenerator object, which I can stub, but I think there will be too many objects.=20 Don't you think it adds unnecessary complexity to split objects to a so fine granularity? Thanks, and I appreciate any comments :-) Tayeb

    Read the article

  • Visual Studio 2010 and Test Driven Development

    - by devoured elysium
    I'm making my first steps in Test Driven Development with Visual Studio. I have some questions regarding how to implement generic classes with VS 2010. First, let's say I want to implement my own version of an ArrayList. I start by creating the following test (I'm using in this case MSTest): [TestMethod] public void Add_10_Items_Remove_10_Items_Check_Size_Is_Zero() { var myArrayList = new MyArrayList<int>(); for (int i = 0; i < 10; ++i) { myArrayList.Add(i); } for (int i = 0; i < 10; ++i) { myArrayList.RemoveAt(0); } int expected = 0; int actual = myArrayList.Size; Assert.AreEqual(expected, actual); } I'm using VS 2010 ability to hit ctrl + . and have it implement classes/methods on the go. I have been getting some trouble when implementing generic classes. For example, when I define an .Add(10) method, VS doesn't know if I intend a generic method(as the class is generic) or an Add(int number) method. Is there any way to differentiate this? The same can happen with return types. Let's assume I'm implementing a MyStack stack and I want to test if after I push and element and pop it, the stack is still empty. We all know pop should return something, but usually, the code of this test shouldn't care for it. Visual Studio would then think that pop is a void method, which in fact is not what one would want. How to deal with this? For each method, should I start by making tests that are "very specific" such as is obvious the method should return something so I don't get this kind of ambiguity? Even if not using the result, should I have something like int popValue = myStack.Pop() ? How should I do tests to generic classes? Only test with one generic kind of type? I have been using ints, as they are easy to use, but should I also test with different kinds of objects? How do you usually approach this? I see there is a popular tool called TestDriven for .NET. With VS 2010 release, is it still useful, or a lot of its features are now part of VS 2010, rendering it kinda useless? Thanks

    Read the article

  • What's the use of writing tests matching configuration-like code line by line?

    - by Pascal Van Hecke
    Hi, I have been wondering about the usefulness of writing tests that match code one-by-one. Just an example: in Rails, you can define 7 restful routes in one line in routes.rb using: resources :products BDD/TDD proscribes you test first and then write code. In order to test the full effect of this line, devs come up with macros e.g. for shoulda: http://kconrails.com/2010/01/27/route-testing-with-shoulda-in-ruby-on-rails/ class RoutingTest < ActionController::TestCase # simple should_map_resources :products end I'm not trying to pick on the guy that wrote the macros, this is just an example of a pattern that I see all over Rails. I'm just wondering what the use of it is... in the end you're just duplicating code and the only thing you test is that Rails works. You could as well write a tool that transforms your test macros into actual code... When I ask around, people answer me that: "the tests should document your code, so yes it makes sense to write them, even if it's just one line corresponding to one line" What are your thoughts?

    Read the article

  • Factorial function - design and test.

    - by lukas
    I'm trying to nail down some interview questions, so I stared with a simple one. Design the factorial function. This function is a leaf (no dependencies - easly testable), so I made it static inside the helper class. public static class MathHelper { public static int Factorial(int n) { Debug.Assert(n >= 0); if (n < 0) { throw new ArgumentException("n cannot be lower that 0"); } Debug.Assert(n <= 12); if (n > 12) { throw new OverflowException("Overflow occurs above 12 factorial"); } //by definition if (n == 0) { return 1; } int factorialOfN = 1; for (int i = 1; i <= n; ++i) { //checked //{ factorialOfN *= i; //} } return factorialOfN; } } Testing: [TestMethod] [ExpectedException(typeof(OverflowException))] public void Overflow() { int temp = FactorialHelper.MathHelper.Factorial(40); } [TestMethod] public void ZeroTest() { int factorialOfZero = FactorialHelper.MathHelper.Factorial(0); Assert.AreEqual(1, factorialOfZero); } [TestMethod] public void FactorialOf5() { int factOf5 = FactorialHelper.MathHelper.Factorial(5); Assert.AreEqual(120,factOf5); } [TestMethod] [ExpectedException(typeof(ArgumentException))] public void NegativeTest() { int factOfMinus5 = FactorialHelper.MathHelper.Factorial(-5); } I have a few questions: Is it correct? (I hope so ;) ) Does it throw right exceptions? Should I use checked context or this trick ( n 12 ) is ok? Is it better to use uint istead of checking for negative values? Future improving: Overload for long, decimal, BigInteger or maybe generic method? Thank you

    Read the article

  • Specify test method name prefix for test suite in junit 3

    - by Marko Kocic
    Is it possible to tell JUnit 3 to use additional method name prefix when looking up test method names? The goal is to have additional tests running locally that should not be run on continuous integration server. CI server doesn't use test suites, it look up for all classes which name ends with "Test" and execute all methods that begins with "test". The goal is to be able to locally run not only tests run by integration server, but also tests which method name starts with, for example "nocitest" or something like that. I don't mind having to organize tests into tests suite locally, since CI is just ignoring them.

    Read the article

  • is there a less bloated way to test constraints in grails?

    - by egervari
    Is there a less bloated way to test constraints? It seems to me that this is too much code to test constraints. class BlogPostTests extends GrailsUnitTestCase { protected void setUp() { super.setUp() mockDomain BlogPost } void testConstraints() { BlogPost blogPost = new BlogPost(title: "", text: "") assertFalse blogPost.validate() assertEquals 2, blogPost.errors.getErrorCount() assertEquals "blank", blogPost.errors.getFieldError("title").getCode() assertEquals "blank", blogPost.errors.getFieldError("text").getCode() blogPost = new BlogPost(title: "title", text: ObjectMother.bigText(2001)) assertFalse blogPost.validate() assertEquals 1, blogPost.errors.getErrorCount() assertEquals "maxSize.exceeded", blogPost.errors.getFieldError("text").getCode() } }

    Read the article

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