Search Results

Search found 7802 results on 313 pages for 'unit tests'.

Page 17/313 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Unit testing a SQL code generator

    - by Tom H.
    The team I'm on is currently writing code in TSQL to generate TSQL code that will be saved as scripts and later run. We're having a little difficulty in separating our unit tests between testing the code generator parts and testing the actual code that they generate. I've read through another similar question, but I was hoping to get some specific examples of what kind of unit test cases we might have. As an example, let's say that I have a bit of code that simply generates a DROP statement for a view, given the view schema and name. Do I just test that the generated code matches some expected outcome using string comparisons and then in a later integration or system test make sure that the drop actually drops the view if it exists, does nothing if the view doesn't exist, or raises an error if the view is one that we are marking as not allowing a drop? Thanks for any advice!

    Read the article

  • Unit Testing Model Classes that derive from NSManagedObject

    - by Matt Baker
    So...I'm trying to get unit tests set up in my iPhone App but I'm having some issues. I'm trying to test my model classes but they inherit directly from NSManagedObject. I'm sure this is a problem but I don't know how to get around it. Everything is building and running as expected but I get this error when calling any method on the class I'm testing: Unknown.m:0:0 unrecognized selector sent to instance 0xc2b120 If I follow this structure (http://chanson.livejournal.com/115621.html) to create my object in my tests I end up with another error entirely but it still doesn't help me. Basically my question is this: how can I test a class that inherits from NSManagedObject?

    Read the article

  • What is wrong with Stubs for unit testing?

    - by MatthewMartin
    I just watched this funny YouTube Video about unit testing (it's Hitler with fake subtitles chewing out his team for not doing good unit tests--skip it if you're humor impaired) where stubs get roundly criticized. But I don't understand what wrong with stubs. I haven't started using a mocking framework and I haven't started feeling the pain from not using one. Am I in for a world a hurt sometime down the line, having chosen handwritten stubs and fakes instead of mocks (like Rhinomock etc)? (using Fowler's taxonomy) What are the considerations for picking between a mock and handwritten stub?

    Read the article

  • ProgrammingError: (1146, "Table 'test_<DB>.<TABLE>' doesn't exist") when running unit test for Djang

    - by abigblackman
    I'm running a unit test using the Django framework and get this error. Running the actual code does not have this problem, running the unit tests creates a test database on the fly so I suspect the issue lies there. The code that throws the error looks like this member = Member.objects.get(email=email_address) and the model looks like class Member(models.Model): member_id = models.IntegerField(primary_key=True) created_on = models.DateTimeField(editable=False, default=datetime.datetime.utcnow()) flags = models.IntegerField(default=0) email = models.CharField(max_length=150, blank=True) phone = models.CharField(max_length=150, blank=True) country_iso = models.CharField(max_length=6, blank=True) location_id = models.IntegerField(null=True, blank=True) facebook_uid = models.IntegerField(null=True, blank=True) utc_offset = models.IntegerField(null=True, blank=True) tokens = models.CharField(max_length=3000, blank=True) class Meta: db_table = u'member' there's nothing too odd there i can see. the user running the tests has the same permissions to the database server as the user that runs the website where else can I look to see what's going wrong, why is this table not being created?

    Read the article

  • I want to create a common unit test function to check all functions based on parameter

    - by Nilesh Rathod
    I want to create a common unit test function to check all functions based on parameter for e.g commonmethod(string methodname,string paramter1,....) { .... } what logic should i write inside this method so that by passing a actual function in parameter methodname and then the common method should execute that function and should return the output. i am using entity framework for all functions which has been created in my project and now i dont want to create a separate unit test function for each function.just one function should do the job based on different parameters... is that possible.. ?, if so then please provide me an code for same.. Thanks in advance..!!!

    Read the article

  • Unit Testing Model Classes that inherits from NSManagedObject

    - by Matt Baker
    So...I'm trying to get unit tests set up in my iPhone App but I'm having some issues. I'm trying to test my model classes but they inherit directly from NSManagedObject. I'm sure this is a problem but I don't know how to get around it. Everything is building and running as expected but I get this error when calling any method on the class I'm testing: Unknown.m:0:0 unrecognized selector sent to instance 0xc2b120 If I follow this structure (http://chanson.livejournal.com/115621.html) to create my object in my tests I end up with another error entirely but it still doesn't help me. Basically my question is this: how can I test a class that inherits from NSManagedObject?

    Read the article

  • Multiple Asserts in a Unit Test

    - by whatispunk
    I've just finished reading Roy Osherove's "The Art of Unit Testing" and I am trying to adhere to the best practices he lays out in the book. One of those best practices is to not use multiple asserts in a test method. The reason for this rule is fairly clear to me, but it makes me wonder... If I have a method like: public Foo MakeFoo(int x, int y, int z) { Foo f = new Foo(); f.X = x; f.Y = y; f.Z = z; return f; } Must I really write individual unit tests to assert each separate property of Foo is initialized with the supplied value? Is it really all that uncommon to use multiple asserts in a test method? FYI: I am using MSTest.

    Read the article

  • Embeddable unit testing framework for mixed Windows app

    - by Andy Dent
    I want to test portions of a very complex app which includes both a major native Windows component and a substantial WPF GUI. Due to complexities I can't detail, it is impossible to run the native portion independently nor can I isolate the areas I want to test (spare me the lectures, we're talking a huge legacy code base and we do have refactoring plans). I'm looking for a unit test kit I can invoke on the native side but must be able to run with the app launched with the managed portion initialised. That seems to rule out the run executable feature of the cfix Windows unit test kit. I really like their philosophy, like WinUnit, of using DLL compilation as a way to add the reflective capabilities missing in C++ and gain a more NUnit-like experience. Ideally, I want something like WinUnit running within the application code and generating an HTML report. I'm trying to introduce more TDD and having things as lean as possible is important.

    Read the article

  • Wrong code coverage on of unit test

    - by KamilPyc
    I'm using code coverage for unit tests in Xcode. Everything is working except some special cases, for example protocol declaration shows wrong values. If I have : @protocol SomeProtocole <NSObject> @property (nonatomic, readonly) NSObject *example; @end I will get 0% code coverage for this file. But I have unit test that is using class that conforms to that protocol. Only solution I found so far is to filter code coverage raport to not include protocols. But I would like to see real values for protocols. Any one have some solution to fix it?

    Read the article

  • Is my code really not unit-testable?

    - by John
    A lot of code in a current project is directly related to displaying things using a 3rd-party 3D rendering engine. As such, it's easy to say "this is a special case, you can't unit test it". But I wonder if this is a valid excuse... it's easy to think "I am special" but rarely actually the case. Are there types of code which are genuinely not suited for unit-testing? By suitable, I mean "without it taking longer to figure out how to write the test than is worth the effort"... dealing with a ton of 3D math/rendering it could take a lot of work to prove the output of a function is correct compared with just looking at the rendered graphics.

    Read the article

  • Unit Testing: hard dependency MessageBox.Show()

    - by Sean B
    What ways can the SampleConfirmationDialog be unit tested? The SampleConfirmationDialog would be exercised via acceptance tests, however how could we unit test it, seeing as MessageBox is not abstract and no matching interface? public interface IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </summary> /// <returns>True if confirmed, false if not, null if cancelled</returns> bool? Confirm(); } /// <summary> /// Implementation of a confirmation dialog /// </summary> public class SampleConfirmationDialog : IConfirmationDialog { /// <summary> /// Confirms the dialog with the user /// </summary> /// <returns>True if confirmed, false if not, null if cancelled</returns> public bool? Confirm() { return MessageBox.Show("do operation x?", "title", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes; } }

    Read the article

  • Silverlight unit testing (using NUnit)

    - by 1gn1ter
    I'm using NUnit for testing back-end. Unit tests are being executed while building (I'm using TeamCity for continuous building). Now I hove to test front-end (Silverlight 4.0). Because the tests are being executed while building, I have to simulate browser (TypeMock - is not free, isn't it?) could I use NUnit.Mocks somehow?. How to use NUnit for Silverlight testing? I've found WHITE framework could it help? Any other advises about software/frameworks to use for Silverlight unit testing?

    Read the article

  • python unit testing os.remove fails file system

    - by hwjp
    Am doing a bit of unit testing on a function which attempts to open a new file, but should fail if the file already exists. when the function runs sucessfully, the new file is created, so i want to delete it after every test run, but it doesn't seem to be working: class MyObject_Initialisation(unittest.TestCase): def setUp(self): if os.path.exists(TEMPORARY_FILE_NAME): try: os.remove(TEMPORARY_FILE_NAME) except WindowsError: #TODO: can't figure out how to fix this... #time.sleep(3) #self.setUp() #this just loops forever pass def tearDown(self): self.setUp() any thoughts? The Windows Error thrown seems to suggest the file is in use... could it be that the tests are run in parallel threads? I've read elsewhere that it's 'bad practice' to use the filesystem in unit testing, but really? Surely there's a way around this that doesn't invole dummying the filesystem?

    Read the article

  • Write Unit test for sorting

    - by user175084
    I need to write a unit test for a method where I arrange data according to another default list. This is the method. internal AData[] GetDataArrayInInitialSortOrder(ABData aBData) { Dictionary<string,AData > aMap = aBData.ADataArray.ToDictionary(v => v.GroupName, v => v); List<AData> newDataList = new List<AData>(); foreach (AData aData in _viewModel.ADList) newDataList.Add(aMap[aData.GroupName]); return newDataList.ToArray(); } Please help I am new in unit testing and this is not easy for me. Any sample or links are appreciated Thanks

    Read the article

  • TDD, Unit Test and architectural changes

    - by Leandro
    I'm writing an RPC middleware in C++. I have a class named RPCClientProxy that contains a socket client inside: class RPCClientProxy { ... private: Socket* pSocket; ... } The constructor: RPCClientProxy::RPCClientProxy(host, port) { pSocket = new Socket(host, port); } As you can see, I don't need to tell the user that I have a socket inside. Although, to make unit tests for my proxies it would be necessary to create mocks for sockets and pass them to the proxies, and to do so I must use a setter or pass a factory to the sockets in the proxies's constructors. My question: According to TDD, is it acceptable to do it ONLY because the tests? As you can see, these changes would change the way the library is used by a programmer.

    Read the article

  • Throwing special type of exception to terminate unit test

    - by trendl
    Assume I want to write a unit test to test a particular piece of functionality that is implemented within a method. If I wanted to execute the method completely, I would have to do some extra set up work (mock objects expectations etc.). Instead of doing that I use the following approach: - I set up the expectations I'm interested in verifying and then make the tested method throw a special type of exception (e.g. TerminateTestException). - Further down in the unit test I catch the exception and verify the mock object expectations. It works fine but I'm not sure it is good practice. I do not do this regularly, only in cases where it saves me time and effort. One thing that comes to mind as an argument against using this is that throwing exceptions takes long time so the tests execute slower than if I used a different approach.

    Read the article

  • Why are my functional tests failing?

    - by Mongus Pong
    I have generated some scaffolding for my rails app. I am running the generated tests and they are failing. for example test "should create area" do assert_difference('Area.count') do post :create, :area => { :name => 'area1' } end assert_redirected_to area_path(assigns(:area)) end This test is failing saying that : 1) Failure: test_should_create_area(AreasControllerTest) [/test/functional/areas_controller_test.rb:16]: "Area.count" didn't change by 1. <3 expected but was <2. There is only one field in the model : name. I am populating this so it cant be because I am failing to populate the only field. I can run the site and create an area with the name 'area1'. So reality is succeeding, but the test is failing. I cant ask why its failing, because Im sure theres not enough information here for anyone here to know why. Im just stuck at knowing what avenues to go down to work out why the test is failing. Even putting puts into the code dont print out... What steps can I take to track this down?

    Read the article

  • Unit tests and Test Runner problems under .Net 4.0

    - by Brett Rigby
    Hi there, We're trying to migrate a .Net 3.5 solution into .Net 4.0, but are experiencing complications with the testing frameworks that can operate using an assembly that is built using version 4.0 of the .Net Framework. Previously, we used NUnit 2.4.3.0 and NCover 1.5.8.0 within our NAnt scripts, but NUnit 2.4.3.0 doesn't like .Net 4.0 projects. So, we upgraded to a newer version of the NUnit framework within the test project itself, but then found that NCover 1.5.8.0 doesn't support this version of NUnit. We get errors in the code saying words to the effect of the assembly was built using a newer version of the .Net Framework than is currently in use, as it's using .Net Framework 2.0 to run the tools. We then tried using Gallio's Icarus test runner GUI, but found that this and MbUnit only support up to version 3.5 of the .Net Frameword and the result is "the tests will be ignored". In terms of the coverage side of things (for reporting into CruiseControl.net), we have found that PartCover is a good candidate for substituting-out NCover, (as the newer version of NCover is quite dear, and PartCover is free), but this is a few steps down the line yet, as we can't get the test runners to work first!! Can any shed any light on a testnig framework that will run under .Net 4.0 in the same way as I've described above? If not, I fear we may have to revert back to using .Net 3.5 until the manufacturers of the tooling that we're currently using have a chance to upgrade to .Net 4.0. Thanks.

    Read the article

  • Automated UAT/functional tests on Swing applications without source code

    - by jas
    Our team is now working on a big Swing application. Our job basically focuses on writing extensions to the existing framework. A typical job would be adding a new panel/ or adding a new tab with some extra functionalities that suit our need. It seems FEST can help a lot in terms of unit-test our code. I am going to try it out this week. But the question here is if there is a way to do automated functional testing on the whole application. In another word, we do not only need to test our code but also the framework. After all, UAT is the most important part. I am currently considering decompiling the jar files we got into source code then we can identify the components and then use FEST. So, before I get started to give this approach a shot, I think I just ask for ideas and inspirations here. There must be people who have done similar things before. Would be nice if I could learn from the veterans who fought against this before . Thanks,

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >