Tag Archives: testing

How to do unit testing with busted in openresty?

Questions: I have a bunch of lua files which I use to handle different urls in nginx, like this: location /tag { set $env ‘prod’; set $redis_ttl 7776000; content_by_lua_file ‘conf/match.lua’; log_by_lua_file ‘conf/log.lua’; } Each file is a simple script, without any module structure. When the number of lines and files were low, I tested everything… Read More »

Unit testing react component that makes ajax calls using JEST

Questions: I’ve a react component that makes AJAX call in componentDidMount method. While I try to render it using React.addons.TestUtils, the component gets rendered without making AJAX call. How would I test react component using jest so that it makes AJAX call? Should I need to use phantomJS (or browser like env) as well to… Read More »

Testing if object is of generic type in C#

Questions: I would like to perform a test if an object is of a generic type. I’ve tried the following without success: public bool Test() { List<int> list = new List<int>(); return list.GetType() == typeof(List<>); } What am I doing wrong and how do I perform this test? Answers: If you want to check if… Read More »

Is there an AssertEquals for testing XML files?

Questions: I have frequent need to test that XML files are correct and need a way of testing that 2 XML strings (or documents) are identical, such as: XMLAssert.assertEquals(String xmlExpected, String xmlActual); In addition it would be useful to show where the xml documents differed. This should be restricted to documents with standalone=”yes” (i.e. the… Read More »

unit testing and Static methods

Questions: Reading up and picking up on unit testing, trying to make sense of the following post on that explains the hardships of static function calls. I don’t clearly understand this issue. I have always assumed static functions were a nice way of rounding up utility functions in a class. For example, I often use… Read More »

Unit testing void methods?

Questions: What is the best way to unit test a method that doesn’t return anything? Specifically in c#. What I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing that hasn’t been done before but being… Read More »

How to test void method with Junit testing tools?

Questions: I just happen to implement a method void followlink(obj page,obj link) which simply adds page and link to queue. I have unsuccessfully tried to test this kind of method. All I want is to test that in the queue contains page and link received from followlink method. My test class already extends TestCase. So… Read More »

How do you mock out the file system in C# for unit testing?

Questions: Are there any libraries or methods to mock out the file system in C# to write unit tests? In my current case I have methods that check whether certain file exists and read the creation date. I may need more than that in future. Answers: Edit: Install the NuGet package System.IO.Abstractions. This package did… Read More »