dimanche 1 février 2015

Expecting a stackmap frame - Java 8

I am getting this error "Expecting a stackmap frame at this location". I am using Java 8. I know that for Java 7 there is a workaround to use -XX:-UseSplitVerifier to use the less strict verification method. However that option was removed in Java 8. I was wondering if there is any other solution for this. Switching to an earlier Java is not an option.


Getting data out of my app code and into my rspec test

I'm not sure how exactly to approach this kind of test in rspec, or if it is even possible.


My specific scenario is about email confirmation:


1) The user#save method uses SecureRandom to generate a string of bytes (the email confirmation code), Bcrypts it, and stores the result in the database. The original random code (unhashed) is also emailed to the user.


2) My user#confirm_email method takes in the email confirmation code and uses BCrypt to hash it and compare it against the existing hash in the database.'


Everything works fine but I'm unclear how to test the scenario, given that the input to #confirm_email is random, created within #save, and not stored anywhere that my test can access.


Is there a clean way for my code to pass information to my test, outside of method return values? I've considered storing the code in a temp file and then reading the file from the test, but I'm curious if there is a better way.


How can I test this angular promise?

I have the following code:


Controller



angular.module('myApp').controller 'dashboardController', (User) ->

User.find('current').then (data) =>
@currentUser = data


User factory



angular.module('myApp').factory 'User', ($resource) ->

$resource = $resource '/api/v1/users/:id'

@find = (id) ->
$resource.get(id: id).$promise

return this


Controller test



describe 'dashboardController', ->
beforeEach module 'myApp'

beforeEach inject ($controller, User, $rootScope, $q) ->
@dashboardController = $controller 'dashboardController'
@User = User
@$scope = $rootScope
@$q = $q

afterEach ->
@dashboardController = {}
@User = {}
@$scope = {}
@$q = {}

beforeEach ->
@deferredSuccess = @$q.defer()
@deferredSuccess.resolve({foo: 'bar'})

spyOn(@User, 'find').and.returnValue(@deferredSuccess.promise)

it 'should call User.find()', ->
@$scope.$apply()


Test failure message...



Error: Unexpected request: GET /api/v1/users/current
No more request expected
at $httpBackend (/Users/nathan/dev/Swift/admin/bower_components/angular-mocks/angular-mocks.js:1227)

Is it safe to rely on 'Facts' package internals for package testing purposes?

I have a package (yeputons/meteor-smart-publish) which uses observeChanges a lot, and I want to add a test (I use TinyTest right now) which allows me to ensure that all such observers are terminated in the end and no handle.stop() was skipped.


The straightforward way is: add the 'Facts' package (which is Meteor-internal), subscribe to 'meteor_facts' and check for observe-handles property of item with _id="mongo-livedata", which is not very safe because it's all undocumented and can be modified in any way in the future.


Is there any more documented way of checking such things?


phpunit thinks two equal strings are not equal

I'm using some code to convert ISO-8859 string to utf8. Then I want to assert, that it has been converted correctly. The code is:



class EncodingTest extends TestCase {

public function testImapUtf8()
{
$pairs = [
['=?ISO-8859-13?Q?Darba_s=E2k=F0ana_ar_Gmail?=', 'Darba sākšana ar Gmail'],
['Normal text', 'Normal text'],
['Darba sākšana ar Gmail', 'Darba sākšana ar Gmail'],
];

foreach ($pairs as $pair) {
$this->assertEquals(($pair[1]), (imap_utf8($pair[0])));
}
}
}


However, for the first pair, it gives me an error:



1) EncodingTest::testImapUtf8
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Darba sākšana ar Gmail'
+'Darba sākšana ar Gmail'


The strings look the same. I guest there are some invisible characters. how do I test that imap_utf8 works as expected?


Should QA/testers write unit-tests?

I work as a test engineer. I mostly work with test-automation on a functional-system level, and performance testing.


I got asked by the scrum-master to start doing some unit-tests, but I have some questions in my mind before I answer that question.



  1. Should testers do unit-tests at all? Isn't that the developers job? Why must I do that?

  2. How hard is unit-testing? Is it easy stuff or complex stuff? I choose this career because I was never a good programmer. But my programming was good enough to start working with test-automation (very easy stuff).


Testing Angular with Mocha returning error

I installed Mocha and Shouldjs using



npm install -g mocha

npm install -g should


to test my Angular app. I copied a test from here, which reads as follows:



describe('addition', function () {
it('should add 1+1 correctly', function (done) {
var onePlusOne = 1 + 1;
onePlusOne.should.equal(2);
// must call done() so that mocha know that we are... done.
// Useful for async tests.
done();
});
});


However, when I run the test using



mocha mytest.js


I get this error:



addition
1) should add 1+1 correctly


0 passing (7ms)
1 failing

1) addition should add 1+1 correctly:
TypeError: Cannot call method 'equal' of undefined
at Context.<anonymous> (C:\wamp\www\myproj\v4\static\src\app\project\overview\overview.spec.js:4:27)
at Test.Runnable.run (C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:218:15)
at Runner.runTest (C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:374:10)
at C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:452:12
at next (C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:299:14)
at C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:309:7
at next (C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:248:23)
at Object._onImmediate (C:\Users\Imray\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:345:15)


Can anyone see how this can be fixed?